Skip to content

Commit be449ab

Browse files
committed
Fix ugettext_lazy objects in Choice tuples not being evaluated. Running .format() on it will return the string we want, and wont cause any problems when its run on a string without arguments
1 parent 0f94f2b commit be449ab

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

graphene/contrib/django/tests/models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
from __future__ import absolute_import
22

33
from django.db import models
4+
from django.utils.translation import ugettext_lazy as _
5+
6+
CHOICES = (
7+
(1, 'this'),
8+
(2, _('that'))
9+
)
410

511

612
class Pet(models.Model):
@@ -22,6 +28,7 @@ class Reporter(models.Model):
2228
last_name = models.CharField(max_length=30)
2329
email = models.EmailField()
2430
pets = models.ManyToManyField('self')
31+
a_choice = models.CharField(max_length=30, choices=CHOICES)
2532

2633
def __str__(self): # __unicode__ on Python 2
2734
return "%s %s" % (self.first_name, self.last_name)

graphene/utils/str_converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ def to_snake_case(name):
1818

1919

2020
def to_const(string):
21-
return re.sub('[\W|^]+', '_', string).upper()
21+
return re.sub('[\W|^]+', '_', string.format()).upper()

0 commit comments

Comments
 (0)