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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...