Unroll choices iterators in field deconstruction
This commit is contained in:
parent
2a30b39f40
commit
f5f556dba3
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue