Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix #20130: regression in {% cache %} template tag. #954

Closed
wants to merge 1 commit into from

3 participants

@bmispelon
Collaborator

No description provided.

@funkybob

Given the regression was hidden because the str method of a fragment returns its original string token, will this test fail?

Collaborator

It does because assertEqual doesn't care about the __str__ method (and FilterExpression doesn't implement any custom __eq__ method).

@timgraham
Owner

merged in 5080311

@timgraham timgraham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 1 deletion.
  1. +1 −1  django/templatetags/cache.py
  2. +5 −0 tests/template_tests/tests.py
View
2  django/templatetags/cache.py
@@ -59,5 +59,5 @@ def do_cache(parser, token):
raise TemplateSyntaxError("'%r' tag requires at least 2 arguments." % tokens[0])
return CacheNode(nodelist,
parser.compile_filter(tokens[1]),
- parser.compile_filter(tokens[2]),
+ tokens[2], # fragment_name can't be a variable.
[parser.compile_filter(token) for token in tokens[3:]])
View
5 tests/template_tests/tests.py
@@ -441,6 +441,11 @@ def gen():
output1 = template.render(Context({'foo': range(3), 'get_value': lambda: next(gen1)}))
self.assertEqual(output1, '[0,1,2,3]', 'Expected [0,1,2,3] in first template, got {0}'.format(output1))
+ def test_cache_regression_20130(self):
+ t = Template('{% load cache %}{% cache 1 regression_20130 %}foo{% endcache %}')
+ cachenode = t.nodelist[1]
+ self.assertEqual(cachenode.fragment_name, 'regression_20130')
+
def test_ifchanged_render_once(self):
""" Test for ticket #19890. The content of ifchanged template tag was
rendered twice."""
Something went wrong with that request. Please try again.