From 74f0408fa2e8e41969a381150f6d78d0cdf3f363 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 26 Jun 2008 04:54:10 +0000 Subject: Fixed #6201 -- Improved the {% cache %} template tag to allow the timeout to be a template variable. Inspired by the patch by zz and edrik git-svn-id: http://code.djangoproject.com/svn/django/trunk@7754 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/cache.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'docs') diff --git a/docs/cache.txt b/docs/cache.txt index e7e1cdd791..3318b2ad4a 100644 --- a/docs/cache.txt +++ b/docs/cache.txt @@ -336,6 +336,17 @@ template tag to uniquely identify the cache fragment:: It's perfectly fine to specify more than one argument to identify the fragment. Simply pass as many arguments to ``{% cache %}`` as you need. +The cache timeout can be a template variable, as long as the template variable +resolves to an integer value. For example, if the template variable +``my_timeout`` is set to the value ``600``, then the following two examples are +equivalent:: + + {% cache 600 sidebar %} ... {% endcache %} + {% cache my_timeout sidebar %} ... {% endcache %} + +This feature is useful in avoiding repetition in templates. You can set the +timeout in a variable, in one place, and just reuse that value. + The low-level cache API ======================= -- cgit v1.3