mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-13 17:52:19 +03:00
fixed field choices realisation
This commit is contained in:
parent
1ecc760a6b
commit
890ef28b85
|
@ -107,8 +107,8 @@ def convert_django_field_with_choices(field, registry=None):
|
|||
return converted
|
||||
choices = getattr(field, "choices", None)
|
||||
if choices:
|
||||
meta = field.model._meta
|
||||
name = to_camel_case("{}_{}".format(meta.object_name, field.name))
|
||||
field_class = field.owner
|
||||
name = to_camel_case("{}_{}".format(field_class.__name__, field.name))
|
||||
choices = list(get_choices(choices))
|
||||
named_choices = [(c[0], c[1]) for c in choices]
|
||||
named_choices_descriptions = {c[0]: c[2] for c in choices}
|
||||
|
@ -119,7 +119,7 @@ def convert_django_field_with_choices(field, registry=None):
|
|||
return named_choices_descriptions[self.name]
|
||||
|
||||
enum = Enum(name, list(named_choices), type=EnumWithDescriptionsType)
|
||||
converted = enum(description=field.help_text, required=not field.null)
|
||||
converted = enum(description=field.help_text, required=field.required)
|
||||
else:
|
||||
converted = convert_django_field(field, registry)
|
||||
if registry is not None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user