1. Create an app and add a page template

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

To create an app:

  1. Open a command prompt and navigate to $SPLUNK_HOME/bin/splunkdj.
  2. If you're using Mac OS X or Unix, enter the following:
  3. ./splunkdj createapp mydjangoapp

    If you're using Windows, enter:

    splunkdj createapp mydjangoapp
  4. You'll need to provide your Splunk username and password to create the app―enter your credentials when prompted.
  5. The $SPLUNK_HOME/etc/apps/mydjangoapp directory is created with auto-generated files for the new "mydjangoapp" app.

  6. Let's add a some meta data. In a text editor, open $SPLUNK_HOME/etc/apps/mydjangoapp/default/app.conf. This file contains the meta data (author, description, version) for your app.
  7. Fill in the "author" and "description" details as you see fit, then save the file.
  8. Restart Splunk.
  9. Open Splunk Web and find your new app:
  10. New apps

  11. Click the title bar or Home link of the app to run it.
  12. Default Home page

Your new Web Framework app is ready. Now let's add a page to the app by creating a page template.

  1. Create a new file called page1.html in the $SPLUNK_HOME/etc/apps/mydjangoapp/django/mydjangoapp/templates/ directory.
  2. Open page1.html in a text editor, and paste in the following boilerplate text for a new page template:
  3. {% extends "splunkdj:base_with_app_bar.html" %}
    {% load splunkmvc %}
    {% block title %}{{app_name}} Your page title goes here{% endblock title %}
    {% block css %}
        <!-- Style sheets are loaded here -->
        <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}{{app_name}}/custom.css" />
        <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}splunkjs/css/dashboard.css" />
            /* Define any page styles here*/
    {% endblock css %}
    {% block content %}
        <!-- You can use HTML and <div> tags for layout -->
        {# Splunk views go here #}
    {% endblock content%}
    {% block managers %}
        {# Search managers go here #}
    {% endblock managers %}
    {% block js %}
        {# JavaScript goes here #}
    {% endblock js %}
  4. Save the page.
  5. Go back to Splunk and view your page. Until we add navigation, the only way to find the page is by manually entering this URL: http://<localhost:port>/dj/mydjangoapp/page1. There isn't much yet, but you should see your new page with the boilerplate setup:
  6. Boilerplate template

In the next step of the tutorial, we'll add some searches and Splunk views. Continue to 2. Add a couple of searches with Splunk views to display results.