HttpRequest Attributes: POST

By: Dusty Arlia
Published on Friday, April 25, 2014, 02:22 PM
Last Updated on Tuesday, July 07, 2015 at 10:33 PM
Total Updates: 2

The POST attribute of Django's HttpRequest Python class is a dictionary-like object containing all the given HTTP POST parameters if the request contains form data (raw, non-form data posted in the request is accessed through the HttpRequest.body attribute instead.).

A request using the POST method can have an empty POST dictionary if for example a form is submitted using the HTTP POST method but does not include form data. For this reason, you shouldn’t use if request.POST to check for use of the HTTP POST method. Instead, you should use if request.method == "POST". Also remember that POST does not include file-upload information (the HttpRequest.FILES attribute does).