Permalink
Browse files

Make sure to use force_unicode when looking up comment objects by `ob…

…ject_pk`. Fixes #8762, and one other bug that nobody's reported yet.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8800 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 429c87f commit a3196dac481410cf6fa7796cfe3b179df2d6a935 @jacobian jacobian committed Sep 1, 2008
Showing with 4 additions and 2 deletions.
  1. +2 −1 django/contrib/comments/forms.py
  2. +2 −1 django/contrib/comments/managers.py
@@ -8,6 +8,7 @@
from django.http import Http404
from django.contrib.contenttypes.models import ContentType
from models import Comment
+from django.utils.encoding import force_unicode
from django.utils.text import get_text_list
from django.utils.translation import ngettext
from django.utils.translation import ugettext_lazy as _
@@ -49,7 +50,7 @@ def get_comment_object(self):
new = Comment(
content_type = ContentType.objects.get_for_model(self.target_object),
- object_pk = str(self.target_object._get_pk_val()),
+ object_pk = force_unicode(self.target_object._get_pk_val()),
user_name = self.cleaned_data["name"],
user_email = self.cleaned_data["email"],
user_url = self.cleaned_data["url"],
@@ -1,6 +1,7 @@
from django.db import models
from django.dispatch import dispatcher
from django.contrib.contenttypes.models import ContentType
+from django.utils.encoding import force_unicode
class CommentManager(models.Manager):
@@ -18,5 +19,5 @@ def for_model(self, model):
ct = ContentType.objects.get_for_model(model)
qs = self.get_query_set().filter(content_type=ct)
if isinstance(model, models.Model):
- qs = qs.filter(object_pk=model._get_pk_val())
+ qs = qs.filter(object_pk=force_unicode(model._get_pk_val()))
return qs

0 comments on commit a3196da

Please sign in to comment.