Check if a template tag is loaded in Django
-
20-09-2019 - |
Question
Is there a way to check if a template tag exists before using the template tag?
In other words, I would like to be able to do something like this:
{% load my_custom_tags %}
...
{% ifloaded my_custom_tags %}
{% some_custom_tag %}
{% endifloaded %}
Solution
You could write your own, custom tag, that would check, if loaded tag is in the current context.
Here are docs: http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow