1👍
✅
You can assign the result of the url
tag to a variable.
{% url 'path.to.view' arg arg2 as the_url %}
{% if the_url %}
<a href="{{ the_url }}">link</a>
{% else %}
No link
{% endif %}
This syntax does not raise an exception if reversing the view fails.
Source:stackexchange.com