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

View File

@ -65,5 +65,5 @@ class ChoicesWidget(forms.Textarea):
if not value: if not value:
return None return None
if type(value) is list: 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 return value