Make sure to use force_unicode when looking up comment objects by `object_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
This commit is contained in:
Jacob Kaplan-Moss 2008-09-01 17:23:09 +00:00
parent 429c87fef8
commit a3196dac48
2 changed files with 4 additions and 2 deletions

View File

@ -8,6 +8,7 @@ from django.conf import settings
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 @@ class CommentForm(forms.Form):
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"],

View File

@ -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 @@ class CommentManager(models.Manager):
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