I'm not sure if this is the "right" way to achieve this, but I use the template tag {% cache%} to get around this. The dynamic bit of the template username is in my base template, and I cache the rest as shown below:
{% extends "base.html" %} {% load cache %} {% block content %} {% cache 86400 key-name %} <h1>My Template in here</h1> {% endcache %} {% endblock content %}
By specifying a key-name, you can use the following in the view to clear the cache if you need to update it manually:
key = django.core.cache.utils.make_template_fragment_key('key-name') cache.delete(key)
source share