diff options
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/cache.txt | 8 | ||||
| -rw-r--r-- | docs/topics/class-based-views/index.txt | 2 | ||||
| -rw-r--r-- | docs/topics/testing/tools.txt | 6 |
3 files changed, 8 insertions, 8 deletions
diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt index ccaa82277f..4e1b2546ad 100644 --- a/docs/topics/cache.txt +++ b/docs/topics/cache.txt @@ -1159,10 +1159,10 @@ In this case, a caching mechanism (such as Django's own cache middleware) will cache a separate version of the page for each unique user-agent. The advantage to using the ``vary_on_headers`` decorator rather than manually -setting the ``Vary`` header (using something like -``response['Vary'] = 'user-agent'``) is that the decorator *adds* to the -``Vary`` header (which may already exist), rather than setting it from scratch -and potentially overriding anything that was already in there. +setting the ``Vary`` header (using something like ``response.headers['Vary'] = +'user-agent'``) is that the decorator *adds* to the ``Vary`` header (which may +already exist), rather than setting it from scratch and potentially overriding +anything that was already in there. You can pass multiple headers to ``vary_on_headers()``:: diff --git a/docs/topics/class-based-views/index.txt b/docs/topics/class-based-views/index.txt index 3ec00f7361..8874545469 100644 --- a/docs/topics/class-based-views/index.txt +++ b/docs/topics/class-based-views/index.txt @@ -119,7 +119,7 @@ And the view:: last_book = self.get_queryset().latest('publication_date') response = HttpResponse() # RFC 1123 date format - response['Last-Modified'] = last_book.publication_date.strftime('%a, %d %b %Y %H:%M:%S GMT') + response.headers['Last-Modified'] = last_book.publication_date.strftime('%a, %d %b %Y %H:%M:%S GMT') return response If the view is accessed from a ``GET`` request, an object list is returned in diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 741acd604c..6d96731c79 100644 --- a/docs/topics/testing/tools.txt +++ b/docs/topics/testing/tools.txt @@ -551,9 +551,9 @@ Specifically, a ``Response`` object has the following attributes: If the given URL is not found, accessing this attribute will raise a :exc:`~django.urls.Resolver404` exception. -You can also use dictionary syntax on the response object to query the value -of any settings in the HTTP headers. For example, you could determine the -content type of a response using ``response['Content-Type']``. +As with a normal response, you can also access the headers through +:attr:`.HttpResponse.headers`. For example, you could determine the content +type of a response using ``response.headers['Content-Type']``. Exceptions ---------- |
