summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Wallenstein <halsmit@t-online.de>2011-01-15 01:16:21 +0000
committerJeremy Kerr <jk@ozlabs.org>2011-02-11 08:54:27 +0800
commit47c56dfaceefaa44e5057236a5b63a05f68a981d (patch)
tree76a1e54fc64bee32610719d3cf3ab0c5d6746b49
parentdf79fa039b310ec648e4f027c47980101795a1d8 (diff)
downloadpatchwork-47c56dfaceefaa44e5057236a5b63a05f68a981d.tar.bz2
patchwork-47c56dfaceefaa44e5057236a5b63a05f68a981d.tar.xz
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. [1] http://docs.djangoproject.com/en/1.2/ref/unicode/ Signed-off-by: Dirk Wallenstein <halsmit@t-online.de> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--apps/patchwork/models.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py
index 6842622..5c0ca95 100644
--- a/apps/patchwork/models.py
+++ b/apps/patchwork/models.py
@@ -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):
if self.name:
- return '%s <%s>' % (self.name, self.email)
+ return u'%s <%s>' % (self.name, self.email)
else:
return self.email
@@ -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):
return self.name
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):
person.link_to_user(self.user)
person.save()
- def __str__(self):
+ def __unicode__(self):
return self.name()
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):
return self.name
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):
return self.name
def comments(self):