views:

57

answers:

1

For example, I have a template file called:

filter.html

{{ title }}

code...

What I'd like to do is, on a separate template:

{% with "Filter by Types" as title %}
  {% include "filter.html" %}
{% endwith %}

Currently it can't be done. Could someone explain why that is and an alternative way to achieve this?

Background context:

The app base is used for multiple sites. The site admin would only be able to edit the template files to give them a degree of customization, but not the views.py or other core files. So the {{ title }} variable can't really be sent by the views.py.

+3  A: 

I might be missing something but why not just use extends and block tags?

base.html

{% block title %}Default title{% endblock %}

filter.html

{% extends "base.html" %}
{% block title %}Filter by Types{% endblock %}

Check out the documentation on extends, blocks and template inheritance for more info.

Nimmy Lebby