Dashboards & Visualizations

How to set a Django web framework view as the default on an app?

asieira
Path Finder

So I have discovered that if you build an app entirely using web framework Django binding views, Splunk won't load any of them when the user first enters the app. Instead, it will open the Alerts page below the menu bar. Also, if you have at least one XML-based view, it will be used as the default regardless of the default setting or the ordering in default.xml.

So I was wondering how to build an XML view under data/default/ui/views that would redirect the user to /dj/redirector/some_django_page/.

Has anyone ever managed to do that and care to share?

0 Karma
1 Solution

asieira
Path Finder

So after a bit of testing I have solved this myself. I'll assume the app name is my_app an that the django view that needs to be loaded by default is called dashboard.

First, create appserver/static/redirect.html that will perform the redirect:

<script type="text/javascript">
window.location="/dj/redirector/my_app/dashboard";
</script>

Then, create default/data/ui/views/redirect.xml that loads the HTML file:

<view template="dashboard.html" isVisible="false">
    <module name="ServerSideInclude" layoutPanel="panel_row1_col1">
        <param name="src">redirect.html</param>
    </module>
</view>

Notice that this view is flagged as not visible so that it won't show up on the app menu bar. Finally, all you need to do is make this view the default on default/data/ui/nav/default.xml:

<nav>
    <view default="true" name="redirect"/>
    <a href="/dj/redirector/my_app/dashboard">Dashboard</a>
</nav>

Following the steps above will ensure that when an user enters your app, he/she will be shown the django-based Dashboard page first.

This is a simple if rather ugly hack, but the ideal solution would be for Splunk to allow django-based views to be set as the default view directly. Oh, well, life's not perfect.

View solution in original post

asieira
Path Finder

So after a bit of testing I have solved this myself. I'll assume the app name is my_app an that the django view that needs to be loaded by default is called dashboard.

First, create appserver/static/redirect.html that will perform the redirect:

<script type="text/javascript">
window.location="/dj/redirector/my_app/dashboard";
</script>

Then, create default/data/ui/views/redirect.xml that loads the HTML file:

<view template="dashboard.html" isVisible="false">
    <module name="ServerSideInclude" layoutPanel="panel_row1_col1">
        <param name="src">redirect.html</param>
    </module>
</view>

Notice that this view is flagged as not visible so that it won't show up on the app menu bar. Finally, all you need to do is make this view the default on default/data/ui/nav/default.xml:

<nav>
    <view default="true" name="redirect"/>
    <a href="/dj/redirector/my_app/dashboard">Dashboard</a>
</nav>

Following the steps above will ensure that when an user enters your app, he/she will be shown the django-based Dashboard page first.

This is a simple if rather ugly hack, but the ideal solution would be for Splunk to allow django-based views to be set as the default view directly. Oh, well, life's not perfect.

Get Updates on the Splunk Community!

Splunk Observability Cloud’s AI Assistant in Action Series: Analyzing and ...

This is the second post in our Splunk Observability Cloud’s AI Assistant in Action series, in which we look at ...

Elevate Your Organization with Splunk’s Next Platform Evolution

 Thursday, July 10, 2025  |  11AM PDT / 2PM EDT Whether you're managing complex deployments or looking to ...

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...