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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...