[Django] #26262: Add HTTP response status code to JsonResponse

25 views
Skip to first unread message

Django

unread,
Feb 22, 2016, 10:50:36 AM2/22/16
to django-...@googlegroups.com
#26262: Add HTTP response status code to JsonResponse
-------------------------------+--------------------
Reporter: boussouira | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
The `JsonResponse` class doesn't have/accept a status code, it would be
helpful to add a `status_code` paramtere to this class, for example:


{{{
return JsonResponse({'error':'Unauthorized access'}, status_code=401)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26262>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 22, 2016, 11:18:19 AM2/22/16
to django-...@googlegroups.com
#26262: Add HTTP response status code to JsonResponse
-------------------------------+--------------------------------------
Reporter: boussouira | Owner: nobody
Type: New feature | Status: closed

Component: HTTP handling | Version: 1.9
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_better_patch: => 0
* resolution: => worksforme
* needs_tests: => 0
* needs_docs: => 0


Comment:

Unfortunately due to history, the parameter is named different from the
attribute, i.e. `JsonResponse({'error':'Unauthorized access'},
status=401)`.

--
Ticket URL: <https://code.djangoproject.com/ticket/26262#comment:1>

Django

unread,
Feb 22, 2016, 11:28:16 AM2/22/16
to django-...@googlegroups.com
#26262: Add HTTP response status code to JsonResponse
-------------------------------+--------------------------------------
Reporter: boussouira | Owner: nobody
Type: New feature | Status: closed

Component: HTTP handling | Version: 1.9
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by boussouira):

Great, i didn't see that in the documentation of JsonResponse, is it
missing or i didn't see it?

--
Ticket URL: <https://code.djangoproject.com/ticket/26262#comment:2>

Django

unread,
Feb 22, 2016, 11:37:16 AM2/22/16
to django-...@googlegroups.com
#26262: Add HTTP response status code to JsonResponse
-------------------------------+--------------------------------------
Reporter: boussouira | Owner: nobody
Type: New feature | Status: closed

Component: HTTP handling | Version: 1.9
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by boussouira):

* resolution: worksforme => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/26262#comment:3>

Django

unread,
Feb 22, 2016, 11:40:12 AM2/22/16
to django-...@googlegroups.com
#26262: Add HTTP response status code to JsonResponse
-------------------------------+--------------------------------------
Reporter: boussouira | Owner: nobody
Type: New feature | Status: closed

Component: HTTP handling | Version: 1.9
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by timgraham):

It could be more explicit I suppose. The docs say, "An `HttpResponse`
subclass that helps to create a JSON-encoded response. It inherits most
behavior from its superclass with a couple differences" and documentation
for `__init__()` shows `**kwargs` in addition to the parameters that are
specific for `JSONResponse`.

--
Ticket URL: <https://code.djangoproject.com/ticket/26262#comment:4>

Reply all
Reply to author
Forward
0 new messages