summaryrefslogtreecommitdiff
path: root/django/core
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2013-05-17 15:31:41 -0400
committerDonald Stufft <donald@stufft.io>2013-05-18 11:14:05 -0400
commita19e9d80ffa10f8da43addcaa4ddd440beee8a4d (patch)
tree6c405ce14256de50c1e4a394514a6daaa0410e50 /django/core
parenta0c0cc924e4c6ffd22158f254ed9bc9556f05cc4 (diff)
Fixed #20430 - Enable iterable of iterables for model choices
Allows for any iterable, not just lists or tuples, to be used as the inner item for a list of choices in a model.
Diffstat (limited to 'django/core')
-rw-r--r--django/core/management/validation.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/core/management/validation.py b/django/core/management/validation.py
index 0f0eade569..2040a14582 100644
--- a/django/core/management/validation.py
+++ b/django/core/management/validation.py
@@ -118,8 +118,8 @@ def get_validation_errors(outfile, app=None):
e.add(opts, '"%s": "choices" should be iterable (e.g., a tuple or list).' % f.name)
else:
for c in f.choices:
- if not isinstance(c, (list, tuple)) or len(c) != 2:
- e.add(opts, '"%s": "choices" should be a sequence of two-tuples.' % f.name)
+ if isinstance(c, six.string_types) or not is_iterable(c) or len(c) != 2:
+ e.add(opts, '"%s": "choices" should be a sequence of two-item iterables (e.g. list of 2 item tuples).' % f.name)
if f.db_index not in (None, True, False):
e.add(opts, '"%s": "db_index" should be either None, True or False.' % f.name)