mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-18 20:40:38 +03:00
Fix field model
This commit is contained in:
parent
4936e40258
commit
edfbbf52ef
|
@ -20,8 +20,9 @@ def convert_choices(choices):
|
||||||
|
|
||||||
def convert_django_field_with_choices(field):
|
def convert_django_field_with_choices(field):
|
||||||
choices = getattr(field, 'choices', None)
|
choices = getattr(field, 'choices', None)
|
||||||
if choices:
|
model = getattr(field, 'model', None)
|
||||||
meta = field.model._meta
|
if choices and model:
|
||||||
|
meta = model._meta
|
||||||
name = '{}_{}_{}'.format(meta.app_label, meta.object_name, field.name)
|
name = '{}_{}_{}'.format(meta.app_label, meta.object_name, field.name)
|
||||||
return Enum(name.upper(), list(convert_choices(choices)), description=field.help_text)
|
return Enum(name.upper(), list(convert_choices(choices)), description=field.help_text)
|
||||||
return convert_django_field(field)
|
return convert_django_field(field)
|
||||||
|
|
|
@ -124,7 +124,7 @@ def test_field_with_choices_gettext():
|
||||||
('en', _('English'))
|
('en', _('English'))
|
||||||
))
|
))
|
||||||
|
|
||||||
class TranslatedModel(models.Model):
|
class TranslatedChoicesModel(models.Model):
|
||||||
language = field
|
language = field
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user