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
This commit is contained in:
Sean McArthur 2011-08-22 16:37:14 -07:00
Родитель 8844912ea7
Коммит fe18a4b712
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -1,6 +1,8 @@
from django.template import Library, loader, TemplateSyntaxError, Node, \ from django.template import Library, loader, TemplateSyntaxError, Node, \
Variable, VariableDoesNotExist Variable, VariableDoesNotExist
from django.template.defaultfilters import escapejs from django.template.defaultfilters import escapejs
from django.utils.encoding import smart_str
from utils.helpers import get_random_string from utils.helpers import get_random_string
from base import helpers from base import helpers
@ -89,9 +91,10 @@ class QueryStringNode(Node):
params = {} params = {}
for k, v in self.params.items(): for k, v in self.params.items():
key = smart_str(k)
try: try:
params[k] = Variable(v).resolve(context) params[key] = Variable(v).resolve(context)
except VariableDoesNotExist: except VariableDoesNotExist:
params[k] = None params[key] = None
return helpers.querystring(orig, **params) return helpers.querystring(orig, **params)