Skip to content

Commit b4291e9

Browse files
kimbriancanavanjkimbo
authored andcommitted
Convert MultipleChoiceField to List of type String
1 parent f33223d commit b4291e9

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
@@ -55,9 +55,14 @@ def convert_form_field_to_float(field):
5555
return Float(description=field.help_text, required=field.required)
5656

5757

58+
@convert_form_field.register(forms.MultipleChoiceField)
59+
def convert_form_field_to_string_list(field):
60+
return List(String, description=field.help_text, required=field.required)
61+
62+
5863
@convert_form_field.register(forms.ModelMultipleChoiceField)
5964
@convert_form_field.register(GlobalIDMultipleChoiceField)
60-
def convert_form_field_to_list(field):
65+
def convert_form_field_to_id_list(field):
6166
return List(ID, required=field.required)
6267

6368

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)