summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-04-22 04:55:42 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-04-22 04:55:42 +0000
commitdfe20bb91a03be12322c2fe785709a78fbc50680 (patch)
tree64cb3d68a2b560bb6648c7bbf6f12e4d347f2e08
parent03b46fc8d0223bc884ff9f7728405367eae7e2fc (diff)
unicode: Fixed #4109 -- Converted internal models to have a __unicode__ method.
In most cases this is just a slight performance improvement (saves on later conversions), in a few cases it's a good idea because things like "username" could now be legitimately non-ASCII. git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5059 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/auth/models.py14
-rw-r--r--django/contrib/contenttypes/models.py2
-rw-r--r--django/contrib/flatpages/models.py4
-rw-r--r--django/contrib/redirects/models.py4
-rw-r--r--django/contrib/sites/models.py2
5 files changed, 13 insertions, 13 deletions
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index f686d90e7a..62d5776ef2 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -45,8 +45,8 @@ class Permission(models.Model):
unique_together = (('content_type', 'codename'),)
ordering = ('content_type', 'codename')
- def __str__(self):
- return "%s | %s | %s" % (self.content_type.app_label, self.content_type, self.name)
+ def __unicode__(self):
+ return u"%s | %s | %s" % (self.content_type.app_label, self.content_type, self.name)
class Group(models.Model):
"""Groups are a generic way of categorizing users to apply permissions, or some other label, to those users. A user can belong to any number of groups.
@@ -66,7 +66,7 @@ class Group(models.Model):
class Admin:
search_fields = ('name',)
- def __str__(self):
+ def __unicode__(self):
return self.name
class UserManager(models.Manager):
@@ -122,7 +122,7 @@ class User(models.Model):
list_filter = ('is_staff', 'is_superuser')
search_fields = ('username', 'first_name', 'last_name', 'email')
- def __str__(self):
+ def __unicode__(self):
return self.username
def get_absolute_url(self):
@@ -262,7 +262,7 @@ class Message(models.Model):
user = models.ForeignKey(User)
message = models.TextField(_('message'))
- def __str__(self):
+ def __unicode__(self):
return self.message
class AnonymousUser(object):
@@ -272,8 +272,8 @@ class AnonymousUser(object):
def __init__(self):
pass
- def __str__(self):
- return 'AnonymousUser'
+ def __unicode__(self):
+ return u'AnonymousUser'
def __eq__(self, other):
return isinstance(other, self.__class__)
diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py
index 0a5e68f37e..100532e4de 100644
--- a/django/contrib/contenttypes/models.py
+++ b/django/contrib/contenttypes/models.py
@@ -42,7 +42,7 @@ class ContentType(models.Model):
ordering = ('name',)
unique_together = (('app_label', 'model'),)
- def __str__(self):
+ def __unicode__(self):
return self.name
def model_class(self):
diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py
index 8d0b2c0d90..86a239489d 100644
--- a/django/contrib/flatpages/models.py
+++ b/django/contrib/flatpages/models.py
@@ -26,8 +26,8 @@ class FlatPage(models.Model):
list_filter = ('sites',)
search_fields = ('url', 'title')
- def __str__(self):
- return "%s -- %s" % (self.url, self.title)
+ def __unicode__(self):
+ return u"%s -- %s" % (self.url, self.title)
def get_absolute_url(self):
return self.url
diff --git a/django/contrib/redirects/models.py b/django/contrib/redirects/models.py
index 60205e29f3..791b9c9091 100644
--- a/django/contrib/redirects/models.py
+++ b/django/contrib/redirects/models.py
@@ -20,5 +20,5 @@ class Redirect(models.Model):
list_filter = ('site',)
search_fields = ('old_path', 'new_path')
- def __str__(self):
- return "%s ---> %s" % (self.old_path, self.new_path)
+ def __unicode__(self):
+ return u"%s ---> %s" % (self.old_path, self.new_path)
diff --git a/django/contrib/sites/models.py b/django/contrib/sites/models.py
index df93c543d2..5bce56eba4 100644
--- a/django/contrib/sites/models.py
+++ b/django/contrib/sites/models.py
@@ -19,5 +19,5 @@ class Site(models.Model):
list_display = ('domain', 'name')
search_fields = ('domain', 'name')
- def __str__(self):
+ def __unicode__(self):
return self.domain