Opened 7 years ago
Closed 7 years ago
#30429 closed New feature (wontfix)
Allow different response classes in render().
| Reported by: | Brad | Owned by: | nobody |
|---|---|---|---|
| Component: | HTTP handling | Version: | dev |
| Severity: | Normal | Keywords: | render |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Add a klass (or maybe response_class) parameter to render() that lets user specify a response class other than HttpResponse.
- Allow any subclass of http.HttpResponseBase
- Default to http.HttpResponse
- Do a quick issubclass() check on the argument
PR: https://github.com/django/django/pull/11162
What is the motivation for this?
render() is meant to be a shortcut and a convenience, so I am cautious about giving it too many parameters and defeating its original purpose. But adding this parameter seems straightforward, frequently useful, and a good trade-off in that it's still keeping the function lightweight and adding flexibility without code complexity.
Change History (1)
comment:1 by , 7 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
| Summary: | Allow different response classes in render() → Allow different response classes in render(). |
| Version: | 2.2 → master |
Thanks for the ticket, however
render()is a simple, straightforward, and two line shortcut. IMO we shouldn't add any complexity to it. Addingklass(orresponse_class) will require changes in documentation and can be confusing. Moreover I don't think that your use case is really common, becauserender()returnsHttpResponsesince its introduction in b3d2091681d31bf2a6f8c4a1f9f1fb32393864c8 and as far as I'm concerned it is a a first request to change this.