From: jordan Date: Wed, 13 Apr 2011 17:46:39 +0000 (+0000) Subject: OSQA-650, force unicode when using the __unicode__ method in the Tags model and make... X-Git-Tag: live~336 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/d958b0a69d6cebf7a4465c552d9392449f0e35fc?ds=inline OSQA-650, force unicode when using the __unicode__ method in the Tags model and make the Questions tag filtration using the tag id rather than the tag name. This is likely to generate some encoding issues, if we use the tag ID it would be more stable. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@977 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/models/tag.py b/forum/models/tag.py index 912697b..067488b 100644 --- a/forum/models/tag.py +++ b/forum/models/tag.py @@ -2,7 +2,7 @@ import datetime from base import * from django.utils.translation import ugettext as _ -from django.utils.encoding import smart_unicode +from django.utils.encoding import smart_unicode, force_unicode from forum import modules @@ -27,7 +27,7 @@ class Tag(BaseModel): app_label = 'forum' def __unicode__(self): - return unicode(self.name) + return force_unicode(self.name) def add_to_usage_count(self, value): if self.used_count + value < 0: diff --git a/forum/views/readers.py b/forum/views/readers.py index 2878424..e800487 100644 --- a/forum/views/readers.py +++ b/forum/views/readers.py @@ -108,7 +108,7 @@ def tag(request, tag): raise Http404 # Getting the questions QuerySet - questions = Question.objects.filter(tags__name=smart_unicode(tag.name)) + questions = Question.objects.filter(tags__id=tag.id) if request.method == "GET": user = request.GET.get('user', None)