1
0
mirror of https://github.com/django/django.git synced 2025-07-04 09:49:12 +00:00

[3.2.x] Used :rfc: role in docs/topics/conditional-view-processing.txt.

Backport of f8bab4e0dcdad5cb174998e1b31d74c8434a2477 from main
This commit is contained in:
Mariusz Felisiak 2021-09-21 06:28:28 +02:00
parent d4a587a5fa
commit 51e76c922f

View File

@ -34,14 +34,12 @@ processing functions.
The ``condition`` decorator The ``condition`` decorator
=========================== ===========================
Sometimes (in fact, quite often) you can create functions to rapidly compute the ETag_ Sometimes (in fact, quite often) you can create functions to rapidly compute
value or the last-modified time for a resource, **without** needing to do all the :rfc:`ETag <7232#section-2.3>` value or the last-modified time for a
the computations needed to construct the full view. Django can then use these resource, **without** needing to do all the computations needed to construct
functions to provide an "early bailout" option for the view processing. the full view. Django can then use these functions to provide an
Telling the client that the content has not been modified since the last "early bailout" option for the view processing. Telling the client that the
request, perhaps. content has not been modified since the last request, perhaps.
.. _ETag: https://tools.ietf.org/html/rfc7232#section-2.3
These two functions are passed as parameters to the These two functions are passed as parameters to the
``django.views.decorators.http.condition`` decorator. This decorator uses ``django.views.decorators.http.condition`` decorator. This decorator uses
@ -60,7 +58,8 @@ order, as the view function they are helping to wrap. The function passed
``last_modified_func`` should return a standard datetime value specifying the ``last_modified_func`` should return a standard datetime value specifying the
last time the resource was modified, or ``None`` if the resource doesn't last time the resource was modified, or ``None`` if the resource doesn't
exist. The function passed to the ``etag`` decorator should return a string exist. The function passed to the ``etag`` decorator should return a string
representing the `ETag`_ for the resource, or ``None`` if it doesn't exist. representing the :rfc:`ETag <7232#section-2.3>` for the resource, or ``None``
if it doesn't exist.
The decorator sets the ``ETag`` and ``Last-Modified`` headers on the response The decorator sets the ``ETag`` and ``Last-Modified`` headers on the response
if they are not already set by the view and if the request's method is safe if they are not already set by the view and if the request's method is safe