File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 15
15
16
16
def convert_choices (choices ):
17
17
for value , name in choices :
18
- yield to_const (force_text (name )), value
18
+ if isinstance (name , (tuple , list )):
19
+ for choice in convert_choices (name ):
20
+ yield choice
21
+ else :
22
+ yield to_const (force_text (name )), value
19
23
20
24
21
25
def convert_django_field_with_choices (field ):
22
26
choices = getattr (field , 'choices' , None )
23
- model = getattr (field , 'model' , None )
24
- if choices and model :
25
- meta = model ._meta
27
+ if choices :
28
+ meta = field .model ._meta
26
29
name = '{}_{}_{}' .format (meta .app_label , meta .object_name , field .name )
27
- return Enum (name .upper (), list (convert_choices (choices )), description = field .help_text )
30
+ graphql_choices = list (convert_choices (choices ))
31
+ return Enum (name .upper (), graphql_choices , description = field .help_text )
28
32
return convert_django_field (field )
29
33
30
34
You can’t perform that action at this time.
0 commit comments