From f17ba3f9ec768ead9811c8e93a20328755fcecfd Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 27 Nov 2008 23:09:05 +0100 Subject: [PATCH] Define __unicode__ on models instead of __str__. When the result of __str__ is a unicode object containing non-ascii characters, str(instance) barfs with an encoding error. --- influences/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/influences/models.py b/influences/models.py index ecee87a..f9fc526 100644 --- a/influences/models.py +++ b/influences/models.py @@ -18,7 +18,7 @@ class Character(models.Model): status = models.CharField(max_length=2, choices=STATUS_CHOICES, default='N', verbose_name = _("Status")) player = models.ForeignKey(User, verbose_name = _("Player")) - def __str__(self): + def __unicode__(self): return self.name def get_absolute_url(self): @@ -48,7 +48,7 @@ class Influence(models.Model): result = models.TextField(blank=True,verbose_name = _("Result")) - def __str__(self): + def __unicode__(self): return self.summary def get_absolute_url(self): -- 2.30.2