python3: use force_text to make sure variables are strings

This commit is contained in:
Frédéric Péters 2018-03-25 16:20:18 +02:00
parent abeaccc7c1
commit d4f5c76d0d
1 changed files with 2 additions and 1 deletions

View File

@ -17,6 +17,7 @@
import re
from django.conf import settings
from django.utils.encoding import force_text
from django.template import Context, Template, TemplateSyntaxError, VariableDoesNotExist
from django.utils.http import quote
@ -58,5 +59,5 @@ def get_templated_url(url, context=None):
return '['
if varname not in template_vars:
raise TemplateError('unknown variable %s', varname)
return unicode(template_vars[varname])
return force_text(template_vars[varname])
return re.sub(r'(\[.+?\])', repl, url)