Knowledge Management

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

grossb
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

grossb
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

grossb
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.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...