diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/fields/__init__.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 27d5657078..b380fcbb55 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -316,11 +316,13 @@ class Field(RegisterLookupMixin): if not self.choices: return [] - if not isinstance(self.choices, Iterable) or isinstance(self.choices, str): + if not isinstance(self.choices, Iterable) or isinstance( + self.choices, (str, set, frozenset) + ): return [ checks.Error( - "'choices' must be a mapping (e.g. a dictionary) or an iterable " - "(e.g. a list or tuple).", + "'choices' must be a mapping (e.g. a dictionary) or an " + "ordered iterable (e.g. a list or tuple, but not a set).", obj=self, id="fields.E004", ) |
