I have written 2 custom template tags in Django. The goal is to use one custom tag inside of another. Is it permitted? The template for custom "outer" tag looks like this:
<ul>
{% for type in types %}
{% custom_internal_tag param1 %}
{% endfor %}
</ul>
Which after rendering results in
Invalid block tag: 'custom_internal_tag', expected 'empty' or 'endfor'
Are nested custom tags allowed? What would be the cause of such an error?
They are definitely allowed, but that error can come up because your custom tag is not properly defined, located or loaded.
Make sure all your custom tags are located in your app/templatetags directory and are loaded properly, usually using the @register decorator.
Reference: https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#registering-custom-filters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With