Reputation: 4118
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?
Upvotes: 3
Views: 1511
Reputation: 165242
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
Upvotes: 9