Ticket #11322: middleware_docs.diff

File middleware_docs.diff, 1.6 KB (added by Michael Malone, 15 years ago)
  • docs/topics/http/middleware.txt

     
    107107``request`` is an :class:`~django.http.HttpRequest` object. ``response`` is the
    108108:class:`~django.http. HttpResponse` object returned by a Django view.
    109109
    110 ``process_response()`` should return an :class:`~django.http. HttpResponse`
     110``process_response()`` must return an :class:`~django.http. HttpResponse`
    111111object. It could alter the given ``response``, or it could create and return a
    112112brand-new :class:`~django.http. HttpResponse`.
    113113
    114 Remember that your middleware will not be called if another middleware object
    115 returns a response before you. But unlike ``process_request()`` and
    116 ``process_view()``, during the response phase the classes are applied in reverse
    117 order, from the bottom up. This means classes defined at the end of
    118 :setting:`MIDDLEWARE_CLASSES` will be run first.
     114Unlike the ``process_request()`` and ``process_view()`` methods, the
     115``process_response()`` method is always called, even if the ``process_request()``
     116and ``process_view()`` methods of the same middleware class were skipped because
     117an earlier middleware method returned an :class:`~django.http. HttpResponse`
     118(this means that your ``process_response()`` method cannot rely on setup done in
     119``process_request()``, for example). In addition, during the response phase the
     120classes are applied in reverse order, from the bottom up. This means classes
     121defined at the end of :setting:`MIDDLEWARE_CLASSES` will be run first.
    119122
    120123.. _exception-middleware:
    121124
Back to Top