14467 change ChoiceField separator from comma to colon

This commit is contained in:
Arthur 2023-12-07 13:14:01 -08:00
parent e59ee3e01e
commit 8d4001ef33
2 changed files with 4 additions and 4 deletions

View File

@ -95,8 +95,8 @@ class CustomFieldChoiceSetForm(BootstrapMixin, forms.ModelForm):
required=False,
help_text=mark_safe(_(
'Enter one choice per line. An optional label may be specified for each choice by appending it with a '
'comma. Example:'
) + ' <code>choice1,First Choice</code>')
'colon. Example:'
) + ' <code>choice1:First Choice</code>')
)
class Meta:
@ -107,7 +107,7 @@ class CustomFieldChoiceSetForm(BootstrapMixin, forms.ModelForm):
data = []
for line in self.cleaned_data['extra_choices'].splitlines():
try:
value, label = line.split(',', maxsplit=1)
value, label = line.split(':', maxsplit=1)
except ValueError:
value, label = line, line
data.append((value, label))

View File

@ -65,5 +65,5 @@ class ChoicesWidget(forms.Textarea):
if not value:
return None
if type(value) is list:
return '\n'.join([f'{k},{v}' for k, v in value])
return '\n'.join([f'{k}:{v}' for k, v in value])
return value