From b15673c52566dbf1fb1f29005901fda35bd97373 Mon Sep 17 00:00:00 2001 From: Sergey Tereschenko Date: Wed, 5 Sep 2018 11:53:15 +0300 Subject: [PATCH] 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 --- mongoengine/base/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine/base/document.py b/mongoengine/base/document.py index 85906a3e..aaf99ace 100644 --- a/mongoengine/base/document.py +++ b/mongoengine/base/document.py @@ -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