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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...