Code

Ticket #2095: choices.diff

File choices.diff, 836 bytes (added by Matias Hermanrud Fjeld, 8 years ago)
Line 
1Index: core/management.py
2===================================================================
3--- core/management.py  (revision 3087)
4+++ core/management.py  (working copy)
5@@ -836,8 +836,8 @@
6             if f.prepopulate_from is not None and type(f.prepopulate_from) not in (list, tuple):
7                 e.add(opts, '"%s": prepopulate_from should be a list or tuple.' % f.name)
8             if f.choices:
9-                if not type(f.choices) in (tuple, list):
10-                    e.add(opts, '"%s": "choices" should be either a tuple or list.' % f.name)
11+                if not hasattr(f.choices, '__iter__'):
12+                    e.add(opts, '"%s": "choices" should be a sequence.' % f.name)
13                 else:
14                     for c in f.choices:
15                         if not type(c) in (tuple, list) or len(c) != 2: