Base templates in Django Bindings

Django Bindings has been deprecated. For more, see the Deprecation Notice.

To simplify the process of creating apps, Django Bindings includes a collection of base templates that include much of the repeated functionality, laying the groundwork for you so that you can get started quickly.

Base templates use inheritance, starting with a parent template that contains the basic structure of an HTML page with the common elements for a Web Framework app, such as the required code libraries, styles, header, footer, and body. Child templates inherit the structure from a parent template and fill in the details by overriding these elements. The collection of base templates in the Web Framework provide a range of features, starting with the most basic, and each base template builds on the previous one to add more Splunk UI features. When your page template inherits from one of these base templates, the details of loading libraries and components are taken care of.

The Web Framework includes the following base templates:

Base template

Description

base.htmlDefines the default basic block structure for the Web Framework templates. This template also includes metadata fields, such as the author and description.
base_with_basic_styles.htmlExtends base.html. This template also loads the Web Framework library, the Web Framework components, and all styles and default script libraries that are required to implement an app with Splunk's look and feel.
base_with_footer.htmlExtends base_with_basic_styles.html. This template also includes a Splunk-style footer region.
base_with_account_bar.htmlExtends base_with_footer.html. This template also includes Splunk chrome and system menus.
base_with_app_bar.htmlExtends base_with_account_bar.html. This template also includes the Help and About menus and app navigation.

 

More about template inheritance

You can extend the base templates and create your own templates to suit your needs. Here's an example that shows how you might specify a style sheet to use.

Base templates contain blocks (contained within the {% block %}...{% endblock %} tags), which are filled in by child templates that inherit from it. Here, the parent template provides an empty CSS block as a placeholder for a style sheet:

. . .
<head>
    . . .
    {% block css %}
    {% endblock css %}
    . . .
</head>
. . .

A child template that inherits from (and extends) this parent template fills in the specific CSS details:

{% extends "parent_template.html" %}
{% block css %}
    <link rel="stylesheet" type="text/css" href="path_and_filename.css" />
{% endblock css %}

When a page template based on this child template is rendered in HTML, the content in the <head> tag contains the CSS that was specified in the {% block css %} template tag:

<html>
<head>
    ...
    <link rel="stylesheet" href="path_and_filename.css" />
    ...
</head>
<body>
...
</body>
</html>

So, in addition to using the included base templates, you can also create your own templates. For more information about parent templates, see Django's documentation.