mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 12:16:58 +03:00
Use Django forcetext for choices
This commit is contained in:
parent
be449ab1c0
commit
7f6598518e
|
@ -1,4 +1,5 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
from ...core.classtypes.enum import Enum
|
from ...core.classtypes.enum import Enum
|
||||||
from ...core.types.custom_scalars import DateTime, JSONString
|
from ...core.types.custom_scalars import DateTime, JSONString
|
||||||
|
@ -14,7 +15,7 @@ singledispatch = import_single_dispatch()
|
||||||
|
|
||||||
def convert_choices(choices):
|
def convert_choices(choices):
|
||||||
for value, name in choices:
|
for value, name in choices:
|
||||||
yield to_const(name), value
|
yield to_const(force_text(name)), value
|
||||||
|
|
||||||
|
|
||||||
def convert_django_field_with_choices(field):
|
def convert_django_field_with_choices(field):
|
||||||
|
|
|
@ -18,4 +18,4 @@ def to_snake_case(name):
|
||||||
|
|
||||||
|
|
||||||
def to_const(string):
|
def to_const(string):
|
||||||
return re.sub('[\W|^]+', '_', string.format()).upper()
|
return re.sub('[\W|^]+', '_', string).upper()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user