Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#28469 closed New feature (fixed)

Add additional response type subclasses

Reported by: Adam Johnson Owned by: nobody
Component: HTTP handling Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

In the past Django has refused to add more HttpResponse subclasses to support all the codes listed in the HTTP RFC, e.g. in #9943, HttpResponseNoContent in #3362, etc.

A recent discussion on the django-developers mailing list came to the consensus that adding them would be a win. It also pointed out existing implementations in django-extras.

They should be added to Django core.

Change History (5)

comment:1 by Tim Graham, 7 years ago

Description: modified (diff)
Summary: Add "missing" response type subclassesAdd additional response type subclasses
Triage Stage: UnreviewedAccepted

As I mentioned on the mailing list, I don't think we should add subclasses if they don't provide any functionality besides a different status code. For that, we could document this pattern:

from http import HTTPStatus
HttpResponse(status=HTTPStatus.NO_CONTENT) 

If a response subclass provides some other additional functionality, I'm open to adding it.

comment:2 by Baptiste Mispelon, 5 years ago

Has patch: set

I took a first stab at a documentation patch for this: https://github.com/django/django/pull/12126

comment:3 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: newclosed

In 9f1ec9e:

Fixed #28469 -- Doc'd how to create a custom HttpResponse subclass.

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 76e0846c:

[3.0.x] Fixed #28469 -- Doc'd how to create a custom HttpResponse subclass.

Backport of 9f1ec9efc35bbb375c9cebb3e0d8c1b7be838338 from master

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In ad56858e:

[2.2.x] Fixed #28469 -- Doc'd how to create a custom HttpResponse subclass.

Backport of 9f1ec9efc35bbb375c9cebb3e0d8c1b7be838338 from master

Note: See TracTickets for help on using tickets.
Back to Top