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?
file inclusion (or transclusion)
{% %} and {{ }} are part of Django templating language. They are used to pass the variables from views to template. {% %} is basically used when you have an expression and are called tags while {{ }} is used to simply access the variable.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With