Permalink
Browse files

bugfix: category page doesn't display

The reason that this happened was that
django.core.urlresolvers.reverse() , which is used in a templatetag,
does not accept unicode keywords. So anytime it gets called, make sure
to encode the keyword in kwargs before passing it to reverse()
  • Loading branch information...
1 parent bdb5640 commit e531bd9233a75a624aeffab1ef4ab73ff59c8ecb @dduan committed Aug 4, 2010
Showing with 6 additions and 4 deletions.
  1. +6 −4 sophie/templatetags/sophie_parts.py
@@ -16,23 +16,25 @@ def sophie_shows_feed_of(blog):
@register.inclusion_tag('sophie/templatetags/links_siblings_of.tag')
def sophie_links_siblings_of(page, blog, urlname, part_slug=None):
# conditional operatior hack xx and yy or zz == xx ? yy : zz
- url_bits = multiblog_enabled and { u'blog_slug': blog.slug } or {}
+ url_bits = multiblog_enabled and { 'blog_slug': blog.slug } or {}
# urls are named following this convention:
# sophie_[part name]_[page type]_url
# which is taken advantage of here:
urlparts = urlname.split('_')
# if the type is 'details', then its url contains a slug of the part
if urlparts[2] == 'details':
- url_bits['%s_slug'%urlparts[1]] = part_slug
+ # django.core.urlresolvers.reverse() does not accept unicode keywords
+ # which is why this part needs encoding
+ url_bits[('%s_slug' % urlparts[1]).encode('utf8')] = part_slug
# Note that previous_page_number() is dumb, it returns the number
# regardless of whether that page exists, same with next_page_number.
# So, this needs to be guarded in the template
- url_bits[u'page_num'] = unicode(page.previous_page_number())
+ url_bits['page_num'] = page.previous_page_number()
previous_link = reverse( urlname, kwargs=url_bits )
- url_bits[u'page_num'] = unicode(page.next_page_number())
+ url_bits['page_num'] = page.next_page_number()
next_link = reverse( urlname, kwargs=url_bits )
return {

0 comments on commit e531bd9

Please sign in to comment.