From f5f556dba3c89333d4533e0603de79b62083d807 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sat, 25 Jan 2014 00:23:28 +0000 Subject: [PATCH] Unroll choices iterators in field deconstruction --- django/db/models/fields/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index e61d079f0d..dca7fb7a6c 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -329,6 +329,10 @@ class Field(RegisterLookupMixin): equals_comparison = set(["choices", "validators", "db_tablespace"]) for name, default in possibles.items(): value = getattr(self, attr_overrides.get(name, name)) + # Unroll anything iterable for choices into a concrete list + if name == "choices" and isinstance(value, collections.Iterable): + value = list(value) + # Do correct kind of comparison if name in equals_comparison: if value != default: keywords[name] = value