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.

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Mastering Threat Intelligence in ES 8.5, Splunk AI Assistant v2, and More from Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Break the Build: Inside the KubeDoom Lounge at .conf26

    You step up to the machine. The pixelated corridors of a certain 1993 FPS load in front of you, EMP Pulse ...

Splunk Auto Ingestion Parallel Pipeline Scaling

Why this feature matters Many Splunk environments experience ingestion pressure long before the host is fully ...