What does "{%" do in HTML?
11,325
It's a template engine syntax use in html pages, django compile it when you render a view html with a context variable and return a basic html response.
In your case your message will be your context variable and django engine compile it like
:
if message is not None then inner part html is visible.
Doc. Link: https://docs.djangoproject.com/en/1.7/topics/templates/
Author by
Amon
Pursuing an educated way of life, in every sense of the word.
Updated on June 06, 2022Comments
-
Amon almost 2 years
I've added Django messages to my app using the official documentation. In it it says to add something like this to my template:
{% if messages %} <ul class="messages"> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> {% endfor %} </ul> {% endif %}
I have no idea what the percentage signs do, they're not actual HTML right?
-
Ignacio Vazquez-Abrams over 7 yearsDjango does not include Jinja. Jinja is a separate project that was created so that Django template syntax could be used independent of Django.