From fe18a4b712703890a3f0767b66da1cf55e2e9350 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Mon, 22 Aug 2011 16:37:14 -0700 Subject: [PATCH] catch search error TypeError: querystring() keywords must be strings strings could come back as unicode, so they must be converted back to a str() before being passed as keyword arguments --- apps/base/templatetags/base_helpers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/base/templatetags/base_helpers.py b/apps/base/templatetags/base_helpers.py index ecb77ee4..eaf25b44 100644 --- a/apps/base/templatetags/base_helpers.py +++ b/apps/base/templatetags/base_helpers.py @@ -1,6 +1,8 @@ from django.template import Library, loader, TemplateSyntaxError, Node, \ Variable, VariableDoesNotExist from django.template.defaultfilters import escapejs +from django.utils.encoding import smart_str + from utils.helpers import get_random_string from base import helpers @@ -89,9 +91,10 @@ class QueryStringNode(Node): params = {} for k, v in self.params.items(): + key = smart_str(k) try: - params[k] = Variable(v).resolve(context) + params[key] = Variable(v).resolve(context) except VariableDoesNotExist: - params[k] = None + params[key] = None return helpers.querystring(orig, **params)