|Version 7 (modified by Gulopine, 8 years ago) (diff)|
Represents an incoming HTTP request, including all HTTP headers and user-submitted data. For information, see the documentation.
Unless otherwise noted, all attributes should be treated as read-only. Additional attributes may be added by middleware, as defined in a project's settings. Some attributes commonly added by middleware are listed here as well, with a link to the middleware documentation.
|path||String containing the full path (not including domain) of the URL requested|
|method||String containing the HTTP method used by the request ('GET' or 'POST')|
|GET||A QueryDict representing form values submitted using the HTTP GET method|
|POST||A QueryDict representing form values submitted using the HTTP POST method|
|raw_post_data||Unprocessed text of the complete POST data, only used in advanced cases, where POST data cannot be parsed into a QueryDict|
|COOKIES||A dictionary of cookies sent by the browser during the request|
|META||A dictionary of included HTTP headers; available headers will vary based on client and server|
|user||A User (or AnonymousUser) object from the authentication middleware|
|session||A special read-write dictionary provided by the sessions middleware|
|build_absolute_uri(location)||Returns an absolute URI for the given location, whether that be relative or absolute|
|has_key(key)||Returns True if the given key was provided in the request (GET or POST). False otherwise|
|get_full_path()||Returns the full request string, including any query string that was provided|
|is_secure()||Returns True if the request was made using HTTPS, False otherwise|
HttpRequest objects allow form data to be retrieved using standard Python dictionary syntax. It will check for GET data first, then POST. Like any dictionary, accessing a non-existant key will result in a KeyError. This access is read-only.
username = request['username']