From: Matthijs Kooijman Date: Thu, 27 Nov 2008 22:09:05 +0000 (+0100) Subject: Define __unicode__ on models instead of __str__. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=f17ba3f9ec768ead9811c8e93a20328755fcecfd;p=matthijs%2Fprojects%2Fxerxes.git 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. --- 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):