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
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).
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With