Skip to content
Browse files

[py3] Always pass bytes to hashlib.md5.

  • Loading branch information...
1 parent 52c351a commit ebc1325721e43808cef4334edaffc23a43f86614 @apollo13 apollo13 committed
Showing with 4 additions and 2 deletions.
  1. +4 −2 django/templatetags/
6 django/templatetags/
@@ -4,6 +4,7 @@
from django.template import Library, Node, TemplateSyntaxError, Variable, VariableDoesNotExist
from django.template import resolve_variable
from django.core.cache import cache
+from django.utils.encoding import smart_bytes
from django.utils.http import urlquote
register = Library()
@@ -24,8 +25,9 @@ def render(self, context):
expire_time = int(expire_time)
except (ValueError, TypeError):
raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time)
- # Build a unicode key for this fragment and all vary-on's.
- args = hashlib.md5(':'.join([urlquote(resolve_variable(var, context)) for var in self.vary_on]))
+ # Build a key for this fragment and all vary-on's.
+ key = smart_bytes(':'.join([urlquote(resolve_variable(var, context)) for var in self.vary_on]))
+ args = hashlib.md5(key)
cache_key = 'template.cache.%s.%s' % (self.fragment_name, args.hexdigest())
value = cache.get(cache_key)
if value is None:

0 comments on commit ebc1325

Please sign in to comment.
Something went wrong with that request. Please try again.