summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorFabrizio Ettore Messina <zauddelig@gmail.com>2018-03-08 16:56:55 +0100
committerTim Graham <timograham@gmail.com>2018-03-08 10:56:55 -0500
commit10c0fe528a2089f4ba206caa50f9a98f8d9c8a15 (patch)
treea78d28e6095e37edea608b981ab727fc3f832778 /django
parent8411e4a8fe98ebac4327ee43446a25873703a5e8 (diff)
Fixed #29178 -- Allowed Index.fields to accept a tuple.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/indexes.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/django/db/models/indexes.py b/django/db/models/indexes.py
index fc24433a33..b601d98492 100644
--- a/django/db/models/indexes.py
+++ b/django/db/models/indexes.py
@@ -12,12 +12,12 @@ class Index:
# cross-database compatibility with Oracle)
max_name_length = 30
- def __init__(self, *, fields=[], name=None, db_tablespace=None):
- if not isinstance(fields, list):
- raise ValueError('Index.fields must be a list.')
+ def __init__(self, *, fields=(), name=None, db_tablespace=None):
+ if not isinstance(fields, (list, tuple)):
+ raise ValueError('Index.fields must be a list or tuple.')
if not fields:
raise ValueError('At least one field is required to define an index.')
- self.fields = fields
+ self.fields = list(fields)
# A list of 2-tuple with the field name and ordering ('' or 'DESC').
self.fields_orders = [
(field_name[1:], 'DESC') if field_name.startswith('-') else (field_name, '')