mirror of
https://github.com/django/django.git
synced 2025-11-13 17:09:28 +00:00
Fixed #24521 -- Added support for serializing frozensets in migrations.
This commit is contained in:
parent
00e667728b
commit
1aadade373
2 changed files with 7 additions and 1 deletions
|
|
@ -302,7 +302,7 @@ class MigrationWriter(object):
|
|||
value = force_text(value)
|
||||
|
||||
# Sequences
|
||||
if isinstance(value, (list, set, tuple)):
|
||||
if isinstance(value, (frozenset, list, set, tuple)):
|
||||
imports = set()
|
||||
strings = []
|
||||
for item in value:
|
||||
|
|
@ -312,6 +312,8 @@ class MigrationWriter(object):
|
|||
if isinstance(value, set):
|
||||
# Don't use the literal "{%s}" as it doesn't support empty set
|
||||
format = "set([%s])"
|
||||
elif isinstance(value, frozenset):
|
||||
format = "frozenset([%s])"
|
||||
elif isinstance(value, tuple):
|
||||
# When len(value)==0, the empty tuple should be serialized as
|
||||
# "()", not "(,)" because (,) is invalid Python syntax.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue