Commit 47c56dfa authored by Dirk Wallenstein's avatar Dirk Wallenstein Committed by Jeremy Kerr
Browse files

models: Implement __unicode__ in models instead of __str__

According to the Django documentation at [1] it is recommended to
implement __unicode__ and not __str__.  Django's model base class
provides a __str__ method that will use the __unicode__ method and
convert to utf-8.  Also, every text value returned from the DB through
the model is unicode.

It is now possible to edit Patches and Persons that have values with
non-ASCII characters through the admin interface.


Signed-off-by: default avatarDirk Wallenstein <>
Signed-off-by: default avatarJeremy Kerr <>
parent df79fa03
......@@ -47,9 +47,9 @@ class Person(models.Model):
name = models.CharField(max_length=255, null = True)
user = models.ForeignKey(User, null = True)
def __str__(self):
def __unicode__(self):
return '%s <%s>' % (,
return u'%s <%s>' % (,
......@@ -66,7 +66,7 @@ class Project(models.Model):
listid = models.CharField(max_length=255, unique=True)
listemail = models.CharField(max_length=200)
def __str__(self):
def __unicode__(self):
class UserProfile(models.Model):
......@@ -84,7 +84,7 @@ class UserProfile(models.Model):
def name(self):
if self.user.first_name or self.user.last_name:
names = filter(bool, [self.user.first_name, self.user.last_name])
return ' '.join(names)
return u' '.join(names)
return self.user.username
def contributor_projects(self):
......@@ -129,7 +129,7 @@ class UserProfile(models.Model):
def __str__(self):
def __unicode__(self):
class State(models.Model):
......@@ -137,7 +137,7 @@ class State(models.Model):
ordering = models.IntegerField(unique = True)
action_required = models.BooleanField(default = True)
def __str__(self):
def __unicode__(self):
class Meta:
......@@ -193,7 +193,7 @@ class Patch(models.Model):
commit_ref = models.CharField(max_length=255, null = True, blank = True)
hash = HashField(null = True, db_index = True)
def __str__(self):
def __unicode__(self):
def comments(self):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment