Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
I am having a custom python script that will get execute like a module or .py file when any user is pressing the "submit" button on the webpage.

How can I get the arguments to be given into a python method from a submit button using Django?

1 Answer

0 votes
by (108k points)

See, generally you need to submit a post request. Then simply intercept the request in your urls.py, where you will call your method. So if your form looks like this:

<form action="submit" method="post">

    <input type="text" name="info"><br>

    <input type="submit" value="Submit">

</form>

Your urls.py would have something like this:

url(r'^submit', views.submit)

This is how your views.py will have the method that would get the arguments that will pass through the post:

def submit(request):

    info=request.POST['info']

    # do something with info

 Want to become a Python Developer? Check out this insightful Python Certification course that will help you out in a better way.

Browse Categories

...