Example: Search controls using tokens and Django tags

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

This example uses Django tags to show how to sync search controls to a search manager using token variables.


To use this code, save it as an HTML file under an existing app in $SPLUNK_HOME/etc/apps/app_name/django/app_name/templates, then view the page in Splunk. For example, to view mypage.html in mysplunkapp, go to http://<localhost:port>/dj/mysplunkapp/mypage. For more about creating an app, see How to create a Web Framework app using Django Bindings.

{% extends "splunkdj:base_with_app_bar.html" %}

{% load splunkmvc %}

{% block title %}Search controls and tokens (Django){% endblock title %}

{% block css %}
        .main-area {
            padding: 30px;
{% endblock css %}

{% block content %}
    <div class="main-area">
        <p>This example shows how to set up SearchBar and SearchControls views using Django tags, and sync them with a SearchManager using tokens.</p>
        <p><b>Note:</b> The Timeline view can't be synced using tokens. Use events instead.</p>

    {% searchbar id="searchbar1" managerid="search1" 
        default="index=_internal | head 100" %}

    {% searchcontrols id="searchcontrols1" managerid="search1" %}

    {% table id="table1" managerid="search1" %}
{% endblock content %}

{% block managers %}
    {% searchmanager id="search1" 
        required_field_list="*" status_buckets=300
{% endblock managers %}