Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Malcolm Tredinnick authored April 22, 2007
14  django/contrib/auth/models.py
@@ -45,8 +45,8 @@ class Meta:
45 45
         unique_together = (('content_type', 'codename'),)
46 46
         ordering = ('content_type', 'codename')
47 47
 
48  
-    def __str__(self):
49  
-        return "%s | %s | %s" % (self.content_type.app_label, self.content_type, self.name)
  48
+    def __unicode__(self):
  49
+        return u"%s | %s | %s" % (self.content_type.app_label, self.content_type, self.name)
50 50
 
51 51
 class Group(models.Model):
52 52
     """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:
66 66
     class Admin:
67 67
         search_fields = ('name',)
68 68
 
69  
-    def __str__(self):
  69
+    def __unicode__(self):
70 70
         return self.name
71 71
 
72 72
 class UserManager(models.Manager):
@@ -122,7 +122,7 @@ class Admin:
122 122
         list_filter = ('is_staff', 'is_superuser')
123 123
         search_fields = ('username', 'first_name', 'last_name', 'email')
124 124
 
125  
-    def __str__(self):
  125
+    def __unicode__(self):
126 126
         return self.username
127 127
 
128 128
     def get_absolute_url(self):
@@ -262,7 +262,7 @@ class Message(models.Model):
262 262
     user = models.ForeignKey(User)
263 263
     message = models.TextField(_('message'))
264 264
 
265  
-    def __str__(self):
  265
+    def __unicode__(self):
266 266
         return self.message
267 267
 
268 268
 class AnonymousUser(object):
@@ -272,8 +272,8 @@ class AnonymousUser(object):
272 272
     def __init__(self):
273 273
         pass
274 274
 
275  
-    def __str__(self):
276  
-        return 'AnonymousUser'
  275
+    def __unicode__(self):
  276
+        return u'AnonymousUser'
277 277
 
278 278
     def __eq__(self, other):
279 279
         return isinstance(other, self.__class__)
2  django/contrib/contenttypes/models.py
@@ -42,7 +42,7 @@ class Meta:
42 42
         ordering = ('name',)
43 43
         unique_together = (('app_label', 'model'),)
44 44
 
45  
-    def __str__(self):
  45
+    def __unicode__(self):
46 46
         return self.name
47 47
 
48 48
     def model_class(self):
4  django/contrib/flatpages/models.py
@@ -26,8 +26,8 @@ class Admin:
26 26
         list_filter = ('sites',)
27 27
         search_fields = ('url', 'title')
28 28
 
29  
-    def __str__(self):
30  
-        return "%s -- %s" % (self.url, self.title)
  29
+    def __unicode__(self):
  30
+        return u"%s -- %s" % (self.url, self.title)
31 31
 
32 32
     def get_absolute_url(self):
33 33
         return self.url
4  django/contrib/redirects/models.py
@@ -20,5 +20,5 @@ class Admin:
20 20
         list_filter = ('site',)
21 21
         search_fields = ('old_path', 'new_path')
22 22
 
23  
-    def __str__(self):
24  
-        return "%s ---> %s" % (self.old_path, self.new_path)
  23
+    def __unicode__(self):
  24
+        return u"%s ---> %s" % (self.old_path, self.new_path)
2  django/contrib/sites/models.py
@@ -19,5 +19,5 @@ class Admin:
19 19
         list_display = ('domain', 'name')
20 20
         search_fields = ('domain', 'name')
21 21
 
22  
-    def __str__(self):
  22
+    def __unicode__(self):
23 23
         return self.domain

0 notes on commit dfe20bb

Please sign in to comment.
Something went wrong with that request. Please try again.