Fix field model

This commit is contained in:
Syrus Akbary 2016-05-31 20:00:31 -07:00
parent 4936e40258
commit edfbbf52ef
2 changed files with 4 additions and 3 deletions

View File

@ -20,8 +20,9 @@ def convert_choices(choices):
def convert_django_field_with_choices(field):
choices = getattr(field, 'choices', None)
if choices:
meta = field.model._meta
model = getattr(field, 'model', None)
if choices and model:
meta = model._meta
name = '{}_{}_{}'.format(meta.app_label, meta.object_name, field.name)
return Enum(name.upper(), list(convert_choices(choices)), description=field.help_text)
return convert_django_field(field)

View File

@ -124,7 +124,7 @@ def test_field_with_choices_gettext():
('en', _('English'))
))
class TranslatedModel(models.Model):
class TranslatedChoicesModel(models.Model):
language = field
class Meta: