5. Add navigation to the app

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

The last step in this tutorial shows how you can set up the navigation for your app. We'll modify the navigation bar to include a link to our page template, which also appears on the main Splunk landing page.

  1. In a text editor, open default.xml from the app's nav directory ($SPLUNK_HOME/etc/apps/mydjangoapp/default/data/ui/nav/).
  2. Now we'll add a link to our page template, page1.html. We can also change the color of the app navigation bar.
  3. Replace the code on this page with the following:

    <nav color="6666FF">
        <view name="default" default="true"/>
        <a href="/dj/redirector/mydjangoapp/home">Home</a>
        <a href="/dj/mydjangoapp/page1">My awesome dashboard</a>
    </nav>
    
  4. Save the file. This time, to see changes to the navigation file, you need to refresh the app by opening the http://<localhost:port>/debug/refresh URL in your web browser, click Refresh, then go to Splunk's Home page at http://<localhost:port>/app/launcher/home.
  5. Apps page

    You'll see the mydjangoapp now displayed in color with a direct link to the page.

  6. Click on the page to see the navigation bar in action:
  7. App with navigation

    However, if you click Home, you'll see that the navigation bar disappears. That's because the Home page is using a base template that does not include the navigation bar. It's an easy fix.

  8. Open home.html from the app's templates directory ($SPLUNK_HOME/etc/apps/mydjangoapp/django/mydjangoapp/templates/).
  9. Find the first line:
  10. {% extends "splunkdj:base_with_account_bar.html" %}
    
  11. Replace it with this:
  12. {% extends "splunkdj:base_with_app_bar.html" %}
    
  13. Save your changes, then view the app in Splunk by going to http://<localhost:port>/dj/mydjangoapp/. The app Home page now displays a navigation bar.

That's it. To learn more about using Django Bindings, see The Django Bindings component of the Splunk Web Framework.