Categories
Python Answers

How to take values from a POST request with Python Django?

Spread the love

Sometimes, we want to take values from a POST request with Python Django.

In this article, we’ll look at how to take values from a POST request with Python Django.

How to take values from a POST request with Python Django?

To take values from a POST request with Python Django, we can use request.POST.

For instance, we write

<input type="hidden" name="title" value="{{ source.title }}">

in our template.

Then in a view, we write

request.POST.get("title", "")

to get the input’s value by calling get with the name attribute value of the input field.

Conclusion

To take values from a POST request with Python Django, we can use request.POST.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *