diff --git a/django/templatetags/cache.py b/django/templatetags/cache.py
index 056eadc..6b5839c 100644
a
|
b
|
from __future__ import unicode_literals
|
2 | 2 | |
3 | 3 | import hashlib |
4 | 4 | from django.template import Library, Node, TemplateSyntaxError, Variable, VariableDoesNotExist |
5 | | from django.template import resolve_variable |
6 | 5 | from django.core.cache import cache |
7 | 6 | from django.utils.http import urlquote |
8 | 7 | |
… |
… |
class CacheNode(Node):
|
25 | 24 | except (ValueError, TypeError): |
26 | 25 | raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time) |
27 | 26 | # Build a unicode key for this fragment and all vary-on's. |
28 | | args = hashlib.md5(':'.join([urlquote(resolve_variable(var, context)) for var in self.vary_on])) |
| 27 | args = hashlib.md5(':'.join([urlquote(var.resolve(context)) for var in self.vary_on])) |
29 | 28 | cache_key = 'template.cache.%s.%s' % (self.fragment_name, args.hexdigest()) |
30 | 29 | value = cache.get(cache_key) |
31 | 30 | if value is None: |
… |
… |
def do_cache(parser, token):
|
60 | 59 | tokens = token.contents.split() |
61 | 60 | if len(tokens) < 3: |
62 | 61 | raise TemplateSyntaxError("'%r' tag requires at least 2 arguments." % tokens[0]) |
63 | | return CacheNode(nodelist, tokens[1], tokens[2], tokens[3:]) |
| 62 | return CacheNode(nodelist, tokens[1], tokens[2], [parser.compile_filter(token) for token in tokens[3:]]) |
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 4aa71f9..307861c 100644
a
|
b
|
from django.utils.formats import date_format
|
28 | 28 | from django.utils.translation import activate, deactivate, ugettext as _ |
29 | 29 | from django.utils.safestring import mark_safe |
30 | 30 | from django.utils.tzinfo import LocalTimezone |
| 31 | from django.http import QueryDict |
31 | 32 | |
32 | 33 | from .callables import CallableVariablesTests |
33 | 34 | from .context import ContextTests |
… |
… |
class Templates(unittest.TestCase):
|
1563 | 1564 | # Regression test for #11270. |
1564 | 1565 | 'cache17': ('{% load cache %}{% cache 10 long_cache_key poem %}Some Content{% endcache %}', {'poem': 'Oh freddled gruntbuggly/Thy micturations are to me/As plurdled gabbleblotchits/On a lurgid bee/That mordiously hath bitled out/Its earted jurtles/Into a rancid festering/Or else I shall rend thee in the gobberwarts with my blurglecruncheon/See if I dont.'}, 'Some Content'), |
1565 | 1566 | |
| 1567 | # Regression tests for #18260 |
| 1568 | 'cache18': ('{% load cache %}{% cache 2 frag_name request.GET.abc %}cache18{% endcache %}', {'request': RequestContext(RequestFactory().get("/somepath"), dict_={"GET" : QueryDict("abc=xyz")})}, 'cache18'), |
| 1569 | 'cache19': ('{% load cache %}{% cache 2 frag_name request.GET.abc %}cache19{% endcache %}', {'request': RequestContext(RequestFactory().get("/somepath"), dict_={"GET" : QueryDict("foo=bar")})}, 'cache19'), |
| 1570 | 'cache20': ('{% load cache %}{% cache 2 frag_name request.GET.abc|default:"xyz" %}cache20{% endcache %}', {'request': RequestContext(RequestFactory().get("/somepath"), dict_={"GET" : QueryDict("foo=bar")})}, ('cache18', 'cache19')), |
| 1571 | |
1566 | 1572 | |
1567 | 1573 | ### AUTOESCAPE TAG ############################################## |
1568 | 1574 | 'autoescape-tag01': ("{% autoescape off %}hello{% endautoescape %}", {}, "hello"), |