Preserve the ordering

set made no guarantees about ordering
This commit is contained in:
tcely 2025-02-03 09:16:26 -05:00 committed by GitHub
parent bdfd645097
commit 4a5660be8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -180,7 +180,8 @@ class CommaSepChoiceField(models.CharField):
return '' return ''
if data.all_choice in value: if data.all_choice in value:
return data.all_choice return data.all_choice
return data.separator.join(set(reversed(value))) ordered_unique = list(dict.fromkeys(value))
return data.separator.join(ordered_unique)
# extra functions not used by any parent classes # extra functions not used by any parent classes
def get_all_choices(self): def get_all_choices(self):