Merge pull request #898 from tcely/patch-14
Some checks are pending
CI / info (push) Waiting to run
CI / test (3.10) (push) Waiting to run
CI / test (3.11) (push) Waiting to run
CI / test (3.12) (push) Waiting to run
CI / test (3.8) (push) Waiting to run
CI / test (3.9) (push) Waiting to run
CI / containerise (push) Blocked by required conditions

Handle strings better
This commit is contained in:
meeb 2025-03-28 14:03:54 +11:00 committed by GitHub
commit 4417f90271
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -145,6 +145,9 @@ class CommaSepChoiceField(models.CharField):
# The data was lost; we can regenerate it.
args_dict = {key: self.__dict__[key] for key in CommaSepChoice._fields}
args_dict['selected_choices'] = list(value)
# setting a string manually should not result in characters
if isinstance(value, str) and len(value) > 0:
args_dict['selected_choices'] = value.split(self.separator)
data = CommaSepChoice(**args_dict)
value = data.selected_choices
s_value = super().get_prep_value(value)