diff --git a/docs/ref/middleware.txt b/docs/ref/middleware.txt
index eb746e4..b3ddb23 100644
a
|
b
|
Cache middleware
|
18 | 18 | .. module:: django.middleware.cache |
19 | 19 | :synopsis: Middleware for the site-wide cache. |
20 | 20 | |
21 | | .. class:: django.middleware.cache.UpdateCacheMiddleware |
| 21 | .. class:: UpdateCacheMiddleware |
22 | 22 | |
23 | | .. class:: django.middleware.cache.FetchFromCacheMiddleware |
| 23 | .. class:: FetchFromCacheMiddleware |
24 | 24 | |
25 | 25 | Enable the site-wide cache. If these are enabled, each Django-powered page will |
26 | 26 | be cached for as long as the :setting:`CACHE_MIDDLEWARE_SECONDS` setting |
… |
… |
defines. See the :doc:`cache documentation </topics/cache>`.
|
32 | 32 | .. module:: django.middleware.common |
33 | 33 | :synopsis: Middleware adding "common" conveniences for perfectionists. |
34 | 34 | |
35 | | .. class:: django.middleware.common.CommonMiddleware |
| 35 | .. class:: CommonMiddleware |
36 | 36 | |
37 | 37 | Adds a few conveniences for perfectionists: |
38 | 38 | |
… |
… |
View metadata middleware
|
80 | 80 | .. module:: django.middleware.doc |
81 | 81 | :synopsis: Middleware to help your app self-document. |
82 | 82 | |
83 | | .. class:: django.middleware.doc.XViewMiddleware |
| 83 | .. class:: XViewMiddleware |
84 | 84 | |
85 | 85 | Sends custom ``X-View`` HTTP headers to HEAD requests that come from IP |
86 | 86 | addresses defined in the :setting:`INTERNAL_IPS` setting. This is used by |
… |
… |
GZIP middleware
|
92 | 92 | .. module:: django.middleware.gzip |
93 | 93 | :synopsis: Middleware to serve gziped content for performance. |
94 | 94 | |
95 | | .. class:: django.middleware.gzip.GZipMiddleware |
| 95 | .. class:: GZipMiddleware |
96 | 96 | |
97 | 97 | Compresses content for browsers that understand gzip compression (all modern |
98 | 98 | browsers). |
… |
… |
Conditional GET middleware
|
109 | 109 | .. module:: django.middleware.http |
110 | 110 | :synopsis: Middleware handling advanced HTTP features. |
111 | 111 | |
112 | | .. class:: django.middleware.http.ConditionalGetMiddleware |
| 112 | .. class:: ConditionalGetMiddleware |
113 | 113 | |
114 | 114 | Handles conditional GET operations. If the response has a ``ETag`` or |
115 | 115 | ``Last-Modified`` header, and the request has ``If-None-Match`` or |
… |
… |
Also sets the ``Date`` and ``Content-Length`` response-headers.
|
121 | 121 | Reverse proxy middleware |
122 | 122 | ------------------------ |
123 | 123 | |
124 | | .. class:: django.middleware.http.SetRemoteAddrFromForwardedFor |
| 124 | .. class:: SetRemoteAddrFromForwardedFor |
125 | 125 | |
126 | 126 | .. versionchanged:: 1.1 |
127 | 127 | |
… |
… |
Locale middleware
|
134 | 134 | .. module:: django.middleware.locale |
135 | 135 | :synopsis: Middleware to enable language selection based on the request. |
136 | 136 | |
137 | | .. class:: django.middleware.locale.LocaleMiddleware |
| 137 | .. class:: LocaleMiddleware |
138 | 138 | |
139 | 139 | Enables language selection based on data from the request. It customizes |
140 | 140 | content for each user. See the :doc:`internationalization documentation |
… |
… |
Message middleware
|
146 | 146 | .. module:: django.contrib.messages.middleware |
147 | 147 | :synopsis: Message middleware. |
148 | 148 | |
149 | | .. class:: django.contrib.messages.middleware.MessageMiddleware |
| 149 | .. class:: MessageMiddleware |
150 | 150 | |
151 | 151 | .. versionadded:: 1.2 |
152 | 152 | ``MessageMiddleware`` was added. |
… |
… |
Session middleware
|
160 | 160 | .. module:: django.contrib.sessions.middleware |
161 | 161 | :synopsis: Session middleware. |
162 | 162 | |
163 | | .. class:: django.contrib.sessions.middleware.SessionMiddleware |
| 163 | .. class:: SessionMiddleware |
164 | 164 | |
165 | 165 | Enables session support. See the :doc:`session documentation |
166 | 166 | </topics/http/sessions>`. |
… |
… |
Authentication middleware
|
171 | 171 | .. module:: django.contrib.auth.middleware |
172 | 172 | :synopsis: Authentication middleware. |
173 | 173 | |
174 | | .. class:: django.contrib.auth.middleware.AuthenticationMiddleware |
| 174 | .. class:: AuthenticationMiddleware |
175 | 175 | |
176 | 176 | Adds the ``user`` attribute, representing the currently-logged-in user, to |
177 | 177 | every incoming ``HttpRequest`` object. See :doc:`Authentication in Web requests |
… |
… |
CSRF protection middleware
|
184 | 184 | :synopsis: Middleware adding protection against Cross Site Request |
185 | 185 | Forgeries. |
186 | 186 | |
187 | | .. class:: django.middleware.csrf.CsrfMiddleware |
| 187 | .. class:: CsrfMiddleware |
188 | 188 | |
189 | 189 | .. versionadded:: 1.0 |
190 | 190 | |
… |
… |
Transaction middleware
|
198 | 198 | .. module:: django.middleware.transaction |
199 | 199 | :synopsis: Middleware binding a database transaction to each Web request. |
200 | 200 | |
201 | | .. class:: django.middleware.transaction.TransactionMiddleware |
| 201 | .. class:: TransactionMiddleware |
202 | 202 | |
203 | 203 | Binds commit and rollback to the request/response phase. If a view function |
204 | 204 | runs successfully, a commit is done. If it fails with an exception, a rollback |
diff --git a/docs/topics/http/middleware.txt b/docs/topics/http/middleware.txt
index 24d2a8e..d376c6b 100644
a
|
b
|
dictionary of keyword arguments that will be passed to the view. Neither
|
89 | 89 | (``request``). |
90 | 90 | |
91 | 91 | ``process_view()`` is called just before Django calls the view. It should |
92 | | return either ``None`` or an :class:`~django.http. HttpResponse` object. If it |
| 92 | return either ``None`` or an :class:`~django.http.HttpResponse` object. If it |
93 | 93 | returns ``None``, Django will continue processing this request, executing any |
94 | 94 | other ``process_view()`` middleware and, then, the appropriate view. If it |
95 | | returns an :class:`~django.http. HttpResponse` object, Django won't bother |
| 95 | returns an :class:`~django.http.HttpResponse` object, Django won't bother |
96 | 96 | calling ANY other request, view or exception middleware, or the appropriate |
97 | | view; it'll return that :class:`~django.http. HttpResponse`. Response |
| 97 | view; it'll return that :class:`~django.http.HttpResponse`. Response |
98 | 98 | middleware is always called on every response. |
99 | 99 | |
100 | 100 | .. _response-middleware: |
… |
… |
middleware is always called on every response.
|
105 | 105 | .. method:: process_response(self, request, response) |
106 | 106 | |
107 | 107 | ``request`` is an :class:`~django.http.HttpRequest` object. ``response`` is the |
108 | | :class:`~django.http. HttpResponse` object returned by a Django view. |
| 108 | :class:`~django.http.HttpResponse` object returned by a Django view. |
109 | 109 | |
110 | | ``process_response()`` must return an :class:`~django.http. HttpResponse` |
| 110 | ``process_response()`` must return an :class:`~django.http.HttpResponse` |
111 | 111 | object. It could alter the given ``response``, or it could create and return a |
112 | | brand-new :class:`~django.http. HttpResponse`. |
| 112 | brand-new :class:`~django.http.HttpResponse`. |
113 | 113 | |
114 | 114 | Unlike the ``process_request()`` and ``process_view()`` methods, the |
115 | 115 | ``process_response()`` method is always called, even if the ``process_request()`` |
116 | 116 | and ``process_view()`` methods of the same middleware class were skipped because |
117 | | an earlier middleware method returned an :class:`~django.http. HttpResponse` |
| 117 | an earlier middleware method returned an :class:`~django.http.HttpResponse` |
118 | 118 | (this means that your ``process_response()`` method cannot rely on setup done in |
119 | 119 | ``process_request()``, for example). In addition, during the response phase the |
120 | 120 | classes are applied in reverse order, from the bottom up. This means classes |
… |
… |
defined at the end of :setting:`MIDDLEWARE_CLASSES` will be run first.
|
132 | 132 | |
133 | 133 | Django calls ``process_exception()`` when a view raises an exception. |
134 | 134 | ``process_exception()`` should return either ``None`` or an |
135 | | :class:`~django.http. HttpResponse` object. If it returns an |
136 | | :class:`~django.http. HttpResponse` object, the response will be returned to |
| 135 | :class:`~django.http.HttpResponse` object. If it returns an |
| 136 | :class:`~django.http.HttpResponse` object, the response will be returned to |
137 | 137 | the browser. Otherwise, default exception handling kicks in. |
138 | 138 | |
139 | 139 | Again, middleware are run in reverse order during the response phase, which |