fixed TypeError on translated choices

join expect strings, but if we use django ugettext_lazy like this:

    choices=[(1, _("One")), (2, _("Two"))]

there will be TypeError: sequence item 0: expected string, __proxy__ found

this commif fixes error by converting label to string
This commit is contained in:
Sergey Tereschenko 2018-09-05 11:53:15 +03:00
parent 00363303b1
commit b15673c525

View File

@ -1091,6 +1091,6 @@ class BaseDocument(object):
sep = getattr(field, 'display_sep', ' ')
values = value if field.__class__.__name__ in ('ListField', 'SortedListField') else [value]
return sep.join([
dict(field.choices).get(val, val)
six.text_type(dict(field.choices).get(val, val))
for val in values or []])
return value