Reputation: 963
I am using template to render basic html in django and specify link as below.
<li><a href="{% url 'project:geometry' object.pk %}">Geometry</a></li>
I want to hide this link based on condition using model information.
Does anyone know how to do this?
Upvotes: 0
Views: 1202
Reputation: 1425
You can surround the html in an if statement using the Django template language:
{% if object.something %}
<li><a href="{% url 'project:geometry' object.pk %}">Geometry</a></li>
{% endif %}
You can use operators, filters or complex expressions if object.something
is not a boolean
Upvotes: 3
Reputation: 16174
Django has an if
template tag, see:
https://docs.djangoproject.com/en/2.1/ref/templates/builtins/#if
from the docs:
{% if not athlete_list %}
There are no athletes.
{% endif %}
Upvotes: 0