Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #5909 -- Made the various django.contrib.comment models more ro…

…bust in

the face of non-ASCII characters by giving them a __unicode__ method and
letting the default __repr__ use that. Patches from prairiedogg and scompt.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6742 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c3a867228b34799c9d31f3da3660673fce2d48d0 1 parent f86e54e
@malcolmt malcolmt authored
View
10 django/contrib/comments/models.py
@@ -102,7 +102,7 @@ class Admin:
date_hierarchy = 'submit_date'
search_fields = ('comment', 'user__username')
- def __repr__(self):
+ def __unicode__(self):
return "%s: %s..." % (self.user.username, self.comment[:100])
def get_absolute_url(self):
@@ -190,7 +190,7 @@ class Admin:
date_hierarchy = 'submit_date'
search_fields = ('comment', 'person_name')
- def __repr__(self):
+ def __unicode__(self):
return "%s: %s..." % (self.person_name, self.comment[:100])
def get_absolute_url(self):
@@ -244,7 +244,7 @@ class Meta:
verbose_name_plural = _('karma scores')
unique_together = (('user', 'comment'),)
- def __repr__(self):
+ def __unicode__(self):
return _("%(score)d rating by %(user)s") % {'score': self.score, 'user': self.user}
class UserFlagManager(models.Manager):
@@ -275,7 +275,7 @@ class Meta:
verbose_name_plural = _('user flags')
unique_together = (('user', 'comment'),)
- def __repr__(self):
+ def __unicode__(self):
return _("Flag by %r") % self.user
class ModeratorDeletion(models.Model):
@@ -287,5 +287,5 @@ class Meta:
verbose_name_plural = _('moderator deletions')
unique_together = (('user', 'comment'),)
- def __repr__(self):
+ def __unicode__(self):
return _("Moderator deletion by %r") % self.user
View
13 django/contrib/comments/tests.py
@@ -0,0 +1,13 @@
+# coding: utf-8
+
+r"""
+>>> from django.contrib.comments.models import Comment
+>>> from django.contrib.auth.models import User
+>>> u = User.objects.create_user('commenttestuser', 'commenttest@example.com', 'testpw')
+>>> c = Comment(user=u, comment=u'\xe2')
+>>> c
+<Comment: commenttestuser: â...>
+>>> print c
+commenttestuser: â...
+"""
+
Please sign in to comment.
Something went wrong with that request. Please try again.