From 831d616bce580769c814042500adcc4c3b48488c Mon Sep 17 00:00:00 2001 From: Dmitry Petukhov Date: Fri, 17 Apr 2020 11:33:07 +0800 Subject: [PATCH] fix: __unicode__ must return unicode Because if `str(self.parent)` actually returns something like `\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82` and you try to `print(ModelClosure)`, you will see UnicodeEncodeError --- closuretree/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/closuretree/models.py b/closuretree/models.py index 46bcc5e..82017b6 100644 --- a/closuretree/models.py +++ b/closuretree/models.py @@ -37,7 +37,7 @@ def _closure_model_unicode(self): """__unicode__ implementation for the dynamically created Closure model. """ - return "Closure from %s to %s" % (self.parent, self.child) + return u"Closure from %s to %s" % (self.parent, self.child) def create_closure_model(cls): """Creates a Closure model in the same module as the model."""