From 97acd4d2f92eef8c285bac070d437bf0fd52e071 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 19 Nov 2025 08:22:44 +0100 Subject: Fixed #26609 -- Extended fields.E004 system check for unordered iterables. Co-authored-by: Karl Wooster --- django/db/models/fields/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'django') 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", ) -- cgit v1.3