diff --git a/django/contrib/comments/forms.py b/django/contrib/comments/forms.py index adb2741873..58af4466d0 100644 --- a/django/contrib/comments/forms.py +++ b/django/contrib/comments/forms.py @@ -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"], diff --git a/django/contrib/comments/managers.py b/django/contrib/comments/managers.py index d664fdaca0..a1ac8097da 100644 --- a/django/contrib/comments/managers.py +++ b/django/contrib/comments/managers.py @@ -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