Test if a custom tag exists

Hello everyone,

is there a way to check if a custom tag is available when rendering a template? My use case is to add {% csp_nonce_attr %} to a third party app which should be compatible with Django-versions prior to 6.1 - so plainly including it is not an option.

Are there any generic hints how to achieve compatibility here?

Thanks,
prauscher

I now circumvented this with {% if csp_nonce is not None %} nonce="{{ csp_nonce }}"{% elif request.csp_nonce %} nonce="{{ request.csp_nonce }}"{% endif %} which should support both CSP since django 6.0 and django-csp. Not sure if this is the recommended way though?