Unroll choices iterators in field deconstruction

This commit is contained in:
Andrew Godwin 2014-01-25 00:23:28 +00:00
parent 2a30b39f40
commit f5f556dba3
1 changed files with 4 additions and 0 deletions

View File

@ -329,6 +329,10 @@ class Field(RegisterLookupMixin):
equals_comparison = set(["choices", "validators", "db_tablespace"]) equals_comparison = set(["choices", "validators", "db_tablespace"])
for name, default in possibles.items(): for name, default in possibles.items():
value = getattr(self, attr_overrides.get(name, name)) 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 name in equals_comparison:
if value != default: if value != default:
keywords[name] = value keywords[name] = value