Skip to content

Commit 16c4b21

Browse files
Convert MultipleChoiceField to List of type String
1 parent 090ce6e commit 16c4b21

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

graphene_django/forms/converter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,14 @@ def convert_form_field_to_float(field):
5757
return Float(description=field.help_text, required=field.required)
5858

5959

60+
@convert_form_field.register(forms.MultipleChoiceField)
61+
def convert_form_field_to_string_list(field):
62+
return List(String, description=field.help_text, required=field.required)
63+
64+
6065
@convert_form_field.register(forms.ModelMultipleChoiceField)
6166
@convert_form_field.register(GlobalIDMultipleChoiceField)
62-
def convert_form_field_to_list(field):
67+
def convert_form_field_to_id_list(field):
6368
return List(ID, required=field.required)
6469

6570

graphene_django/forms/tests/test_converter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ def test_should_choice_convert_string():
6666
assert_conversion(forms.ChoiceField, String)
6767

6868

69+
def test_should_multiple_choice_convert_list():
70+
assert_conversion(forms.MultipleChoiceField, List)
71+
72+
6973
def test_should_base_field_convert_string():
7074
assert_conversion(forms.Field, String)
7175

0 commit comments

Comments
 (0)