Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit dfe20bb91a03be12322c2fe785709a78fbc50680 1 parent 03b46fc
@malcolmt malcolmt authored
View
14 django/contrib/auth/models.py
@@ -45,8 +45,8 @@ class Meta:
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 Meta:
class Admin:
search_fields = ('name',)
- def __str__(self):
+ def __unicode__(self):
return self.name
class UserManager(models.Manager):
@@ -122,7 +122,7 @@ class Admin:
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__)
View
2  django/contrib/contenttypes/models.py
@@ -42,7 +42,7 @@ class Meta:
ordering = ('name',)
unique_together = (('app_label', 'model'),)
- def __str__(self):
+ def __unicode__(self):
return self.name
def model_class(self):
View
4 django/contrib/flatpages/models.py
@@ -26,8 +26,8 @@ class Admin:
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
View
4 django/contrib/redirects/models.py
@@ -20,5 +20,5 @@ class Admin:
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)
View
2  django/contrib/sites/models.py
@@ -19,5 +19,5 @@ class Admin:
list_display = ('domain', 'name')
search_fields = ('domain', 'name')
- def __str__(self):
+ def __unicode__(self):
return self.domain
Please sign in to comment.
Something went wrong with that request. Please try again.