Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How check if value exists in request POST? [duplicate]

I submit form using POST method. Form has one input field: time.

I tried to check if exist parameter:

if 'time' in request.data:
   pass

But it does not work

like image 822
Agella Avatar asked Dec 15 '17 23:12

Agella


People also ask

What is if request method == post?

The result of request. method == "POST" is a boolean value - True if the current request from a user was performed using the HTTP "POST" method, of False otherwise (usually that means HTTP "GET", but there are also other methods).

How can I tell if a post request is successful in PHP?

Use isset() method in PHP to test the form is submitted successfully or not. In the code, use isset() function to check $_POST['submit'] method. Remember in place of submit define the name of submit button. After clicking on submit button this action will work as POST method.

How can I get post request in Django?

Django pass POST data to view The input fields defined inside the form pass the data to the redirected URL. You can define this URL in the urls.py file. In this URLs file, you can define the function created inside the view and access the POST data as explained in the above method. You just have to use the HTTPRequest.


1 Answers

You should use request.form if you're posting your data as a regular POST body query, i.e.:

@app.route('/schedule/<int:adv_id>', methods=['POST'])
def schedule(adv_id):
    if "time" in request.form:
        pass  # do whatever you want with it
like image 140
zwer Avatar answered Sep 21 '22 08:09

zwer