Fixed #32002 -- Added headers parameter to HttpResponse and subclasses.

This commit is contained in:
Tom Carrick 2020-09-15 12:43:37 +02:00 committed by Mariusz Felisiak
parent 2e7cc95499
commit dcb69043d0
9 changed files with 115 additions and 32 deletions

View file

@ -117,9 +117,10 @@ And the view::
def head(self, *args, **kwargs):
last_book = self.get_queryset().latest('publication_date')
response = HttpResponse()
# RFC 1123 date format
response.headers['Last-Modified'] = last_book.publication_date.strftime('%a, %d %b %Y %H:%M:%S GMT')
response = HttpResponse(
# RFC 1123 date format.
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