1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #28152 -- Made migrations serialize sets as set literals rather than set().

This commit is contained in:
Jon Dufresne
2017-05-18 06:33:40 -07:00
committed by Tim Graham
parent 912ef7f49d
commit f599747fc8
8 changed files with 15 additions and 8 deletions

View File

@@ -244,8 +244,9 @@ class SequenceSerializer(BaseSequenceSerializer):
class SetSerializer(BaseSequenceSerializer):
def _format(self):
# Don't use the literal "{%s}" as it doesn't support empty set
return "set([%s])"
# Serialize as a set literal except when value is empty because {}
# is an empty dict.
return '{%s}' if self.value else 'set(%s)'
class SettingsReferenceSerializer(BaseSerializer):