Splunk Dev

How to pass the values from django view to python backend files and how retrieve the results from python backend files to django view

UshaReddyDondet
Engager

I am developing an application using django frame work in splunk.

I have created a form which can take input from the user. For this I have created a text box to give input data through html file and created conf file in default folder to initialize the variables and forms.py file to read the input values given by the user, in splunk using django frame work.

After giving input data and on click of Submit button, I have to pass this input data from HTML to python back end files, validate the input data in python backend files. This validated data should be converted in to an object. This object should be sent to another HTML file, and the results in the object should be displayed to the user.

My question is using django frame work,
1) How can I pass the input data given by the user from HTML file to python back end file on click of submit button?
2) How to manipulate the data in python backend file? I am not able to dubug the values stored in a variable in python back end file in views.py file. So how can i do it?
3) How to send the output data from python backend file to HTML file and display the output in the HTML file?

Kindly help me on this.

Tags (1)

ineeman
Splunk Employee
Splunk Employee
  1. You can either use the regular Django Form framework, or you can just regular HTML forms and have it POST to a specific URL, and on the Django side you would configure urls.py to have a proper handler for that URL, and you would get the POST variables there.

  2. Using the above, you would gain access to the POST variables on the Python side (in Django), and would be able to modify them. For debugging, you can either use logging (and it will go to django_service.log in var/logs/splunk), or you can attach a Python debugger (e.g. from PyCharm) to the Python application.

  3. You would use regular Django templates here - you would have any variables on the Python side, and would just give it to the template and render them.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...