Skip to content

Commit

Permalink
Fix ugettext_lazy objects in Choice tuples not being evaluated. Runni…
Browse files Browse the repository at this point in the history
…ng .format() on it will return the string we want, and wont cause any problems when its run on a string without arguments
  • Loading branch information
JCB-K committed May 31, 2016
1 parent 0f94f2b commit be449ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions graphene/contrib/django/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from __future__ import absolute_import

from django.db import models
from django.utils.translation import ugettext_lazy as _

CHOICES = (
(1, 'this'),
(2, _('that'))
)


class Pet(models.Model):
Expand All @@ -22,6 +28,7 @@ class Reporter(models.Model):
last_name = models.CharField(max_length=30)
email = models.EmailField()
pets = models.ManyToManyField('self')
a_choice = models.CharField(max_length=30, choices=CHOICES)

def __str__(self): # __unicode__ on Python 2
return "%s %s" % (self.first_name, self.last_name)
Expand Down
2 changes: 1 addition & 1 deletion graphene/utils/str_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def to_snake_case(name):


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

0 comments on commit be449ab

Please sign in to comment.