============================ Request and response objects ============================ Quick overview ============== Django uses request and response objects to pass state through the system. When a page is requested, Django creates an ``HttpRequest`` object that contains metadata about the request. Then Django loads the appropriate view, passing the ``HttpRequest`` as the first argument to the view function. Each view is responsible for returning an ``HttpResponse`` object. This document explains the APIs for ``HttpRequest`` and ``HttpResponse`` objects. HttpRequest objects =================== Attributes ---------- All attributes except ``session`` should be considered read-only. ``path`` A string representing the full path to the requested page, not including the domain. Example: ``"/music/bands/the_beatles/"`` ``method`` A string representing the HTTP method used in the request. This is guaranteed to be uppercase. Example:: if request.method == 'GET': do_something() elif request.method == 'POST': do_something_else() ``GET`` A dictionary-like object containing all given HTTP GET parameters. See the ``QueryDict`` documentation below. ``POST`` A dictionary-like object containing all given HTTP POST parameters. See the ``QueryDict`` documentation below. It's possible that a request can come in via POST with an empty ``POST`` dictionary -- if, say, a form is requested via the POST HTTP method but does not include form data. Therefore, you shouldn't use ``if request.POST`` to check for use of the POST method; instead, use ``if reuqest.method == "POST"`` (see above). Note: ``POST`` does *not* include file-upload information. See ``FILES``. ``REQUEST`` For convenience, a dictionary-like object that searches ``POST`` first, then ``GET``. Inspired by PHP's ``$_REQUEST``. For example, if ``GET = {"name": "john"}`` and ``POST = {"age": '34'}``, ``REQUEST["name"]`` would be ``"john"``, and ``REQUEST["age"]`` would be ``"34"``. It's strongly suggested that you use ``GET`` and ``POST`` instead of ``REQUEST``, because the former are more explicit. ``COOKIES`` A standard Python dictionary containing all cookies. Keys and values are strings. ``FILES`` A dictionary-like object containing all uploaded files. Each key in ``FILES`` is the ``name`` from the ````. Each value in ``FILES`` is a standard Python dictionary with the following three keys: * ``filename`` -- The name of the uploaded file, as a Python string. * ``content-type`` -- The content type of the uploaded file. * ``content`` -- The raw content of the uploaded file. Note that ``FILES`` will only contain data if the request method was POST and the ``