Django: Assigning variables in template
How can I assign a variable inside the django templating system ?
Assuming Restaurant
is a Model:
{% restaurant_id as restaurant.id %}
or {{ restaurant_id as restaurant.id }}
are not working.
You could use the with template tag, and assign an internal template variable like this:
{% with restaurant_id=restaurant.id %}
... use restaurant_id in this template section ...
{% endwith %}
Note: You can use filters within the "with" template tag:
foo is {{ foo }}
{% with bar=foo|slice'6:9' %}
bar is {{ bar }}
{% endwith %}