diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2025-11-19 08:22:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-19 08:22:44 +0100 |
| commit | 97acd4d2f92eef8c285bac070d437bf0fd52e071 (patch) | |
| tree | 62de2c4f5299318d8cffbf67d544f239c1d7fc07 /django | |
| parent | e05f2a75695b5f5faa7682d4053db4776d4d6f93 (diff) | |
Fixed #26609 -- Extended fields.E004 system check for unordered iterables.
Co-authored-by: Karl Wooster <karl.wooster@alleima.com>
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", ) |
