I am attempting to build a Django template that dynamically handles variables that may or may not exist.
Here is the type of pattern I am using:
{% block unsubscribe %}
{% if unsubscribe_uuid is not None %}
<a href="http://www.example.com/core/unsubscribe/{{ unsubscribe_uuid }}/" style="
font-size: .9em;
color: rgba(255, 255, 255, 0.5);">
unsubscribe</a> |
{% endif %}
{% endblock %}
This throws an error/exception/warning:
django.template.base.VariableDoesNotExist: Failed lookup for key [unsubscribe_uuid]
I've also tried checking with this line to check for the variable:
{% if unsubscribe_uuid %}
How can I check for variables in my template without throwing this error if they don't exists?