Knowledge Management

Using template inheritance, is it possible to use Splunk framework Django tags within a child template?

Explorer

I'm trying to use template inheritance to reuse framework code in other apps. When i attempt to pull out parts into parent and child pages, my child page is erroring on the fact that i have a django tag being used.

"Invalid block tag: 'dropdown', expected 'endblock'"

Is it not possible to use splunk framework django tags within a child template?

0 Karma
1 Solution

Explorer

Alright, so this has been resolved. The answer is yes, template inheritance does worked within splunk apps and the problem i was creating was not defining my parent content blocks that i defined in my child template.

For example.
In the child.html tempate, i defined a content block called:
{% block my_custom_div %}
{% endblock my_custom_div %}

But neglected to include that block within a defined block in the parent.html
Previous broken template:
{% block my_div %}
{% endblock my_div %}

But since this name was not previously defined in my parent, it didn't know how/what to do with it. But adding this block within a previously defined parent block, like:
{% block content %}
{% block my_div %}
{% endblock my_div %}
{% endblock content %}

It will render.
The error specifically calling out the django block tag was because in the template (the child in this case) did not include the "{% load splunkmvc %}" block at the top which is used to make the django dropdown block.

View solution in original post

0 Karma

Explorer

Alright, so this has been resolved. The answer is yes, template inheritance does worked within splunk apps and the problem i was creating was not defining my parent content blocks that i defined in my child template.

For example.
In the child.html tempate, i defined a content block called:
{% block my_custom_div %}
{% endblock my_custom_div %}

But neglected to include that block within a defined block in the parent.html
Previous broken template:
{% block my_div %}
{% endblock my_div %}

But since this name was not previously defined in my parent, it didn't know how/what to do with it. But adding this block within a previously defined parent block, like:
{% block content %}
{% block my_div %}
{% endblock my_div %}
{% endblock content %}

It will render.
The error specifically calling out the django block tag was because in the template (the child in this case) did not include the "{% load splunkmvc %}" block at the top which is used to make the django dropdown block.

View solution in original post

0 Karma