chomp out non-ascii characters from enum name generation

This commit is contained in:
Jason Kraus 2019-05-31 10:57:18 -07:00
parent c4febcde04
commit 3d99b9c05f
2 changed files with 3 additions and 2 deletions

View File

@ -29,7 +29,8 @@ singledispatch = import_single_dispatch()
def convert_choice_name(name): def convert_choice_name(name):
name = to_const(force_text(name)) name = force_text(name).encode('utf8').decode('ascii', 'ignore')
name = to_const(name)
try: try:
assert_valid_name(name) assert_valid_name(name)
except AssertionError: except AssertionError:

View File

@ -3,7 +3,7 @@ from __future__ import absolute_import
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
CHOICES = ((1, "1: this"), (2, _("2: that"))) CHOICES = ((1, "1: this"), (2, _("2: that")))
class Pet(models.Model): class Pet(models.Model):