[feature request] including HttpResponse(status=204) as an HttpResponse subclasses

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[feature request] including HttpResponse(status=204) as an HttpResponse subclasses

iMath
Every Django view function MUST return an HttpResponse object, sometimes we just want to send data to the server and  don't want to send data back to the client , this probably lead Python users want to return None instead, however , this is not allowed in Django view function, I found  HttpResponse(status=204) may come for rescue in this case,  thus it would be better to include HttpResponse(status=204) as an HttpResponse subclasses for convenience so that could save Django users from asking those returning-null-response questions:
http://stackoverflow.com/questions/17557618/post-without-response-in-django-javascript-interaction
http://stackoverflow.com/questions/2131203/django-no-redirections
http://stackoverflow.com/questions/4123155/how-do-i-send-empty-response-in-django-without-templates

BTW, someone already implemented this feature  here, better to adopt it in Django 
http://django-extras.readthedocs.io/en/latest/ref/http-response.html

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/76aefb01-5b00-4df8-9210-4f064ca74aeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [feature request] including HttpResponse(status=204) as an HttpResponse subclasses

Tim Graham-2
Hi, this was already wontfixed here:
https://code.djangoproject.com/ticket/3362

with the rationale, "We've decided in the past not to add a new class for every single response code. You can already pass the status code in when creating the HttpResponse class, so that can be used in this case."

(found with this google search: httpresponse 204 site:code.djangoproject.com)

On Wednesday, April 5, 2017 at 11:25:44 AM UTC-4, Philip Lee wrote:
Every Django view function MUST return an HttpResponse object, sometimes we just want to send data to the server and  don't want to send data back to the client , this probably lead Python users want to return None instead, however , this is not allowed in Django view function, I found  <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.w3.org%2FProtocols%2Frfc2616%2Frfc2616-sec10.html%23sec10\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFNeRNwo63lcJZ54-pKBju_fZUY-Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.w3.org%2FProtocols%2Frfc2616%2Frfc2616-sec10.html%23sec10\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFNeRNwo63lcJZ54-pKBju_fZUY-Q&#39;;return true;">HttpResponse(status=204) may come for rescue in this case,  thus it would be better to include HttpResponse(status=204) as an HttpResponse subclasses for convenience so that could save Django users from asking those returning-null-response questions:
<a href="http://stackoverflow.com/questions/17557618/post-without-response-in-django-javascript-interaction" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F17557618%2Fpost-without-response-in-django-javascript-interaction\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHi5vp1iGUsF8NoNaAyPOmYf3I33A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F17557618%2Fpost-without-response-in-django-javascript-interaction\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHi5vp1iGUsF8NoNaAyPOmYf3I33A&#39;;return true;">http://stackoverflow.com/questions/17557618/post-without-response-in-django-javascript-interaction
<a href="http://stackoverflow.com/questions/2131203/django-no-redirections" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F2131203%2Fdjango-no-redirections\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHoWS6ehm-hr7tVpOyljzGwg1uafA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F2131203%2Fdjango-no-redirections\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHoWS6ehm-hr7tVpOyljzGwg1uafA&#39;;return true;">http://stackoverflow.com/questions/2131203/django-no-redirections
<a href="http://stackoverflow.com/questions/4123155/how-do-i-send-empty-response-in-django-without-templates" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F4123155%2Fhow-do-i-send-empty-response-in-django-without-templates\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHDwf5OXIitLLi3DcW7lFqDIBjf5w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F4123155%2Fhow-do-i-send-empty-response-in-django-without-templates\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHDwf5OXIitLLi3DcW7lFqDIBjf5w&#39;;return true;">http://stackoverflow.com/questions/4123155/how-do-i-send-empty-response-in-django-without-templates

BTW, someone already implemented this feature  here, better to adopt it in Django 
<a href="http://django-extras.readthedocs.io/en/latest/ref/http-response.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdjango-extras.readthedocs.io%2Fen%2Flatest%2Fref%2Fhttp-response.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFG24zDO_abKowRk3ju087tkmDj7Q&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdjango-extras.readthedocs.io%2Fen%2Flatest%2Fref%2Fhttp-response.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFG24zDO_abKowRk3ju087tkmDj7Q&#39;;return true;">http://django-extras.readthedocs.io/en/latest/ref/http-response.html

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/1ad91569-9373-45ec-9307-09e20caf9e6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [feature request] including HttpResponse(status=204) as an HttpResponse subclasses

iMath
I think you'd better write the decision in the document to stop Django users from making the same feature request in future !

On Thursday, April 6, 2017 at 12:35:41 AM UTC+8, Tim Graham wrote:
Hi, this was already wontfixed here:
<a href="https://code.djangoproject.com/ticket/3362" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcode.djangoproject.com%2Fticket%2F3362\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF2-G8uTP6LmDH2mqosZDuQVJWA6A&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcode.djangoproject.com%2Fticket%2F3362\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF2-G8uTP6LmDH2mqosZDuQVJWA6A&#39;;return true;">https://code.djangoproject.com/ticket/3362

with the rationale, "We've decided in the past not to add a new class for every single response code. You can already pass the status code in when creating the HttpResponse class, so that can be used in this case."

(found with this google search: httpresponse 204 site:<a href="http://code.djangoproject.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcode.djangoproject.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFaP1F0AlILoeI6uQV8rqu3oGIWfA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcode.djangoproject.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFaP1F0AlILoeI6uQV8rqu3oGIWfA&#39;;return true;">code.djangoproject.com)

On Wednesday, April 5, 2017 at 11:25:44 AM UTC-4, Philip Lee wrote:
Every Django view function MUST return an HttpResponse object, sometimes we just want to send data to the server and  don't want to send data back to the client , this probably lead Python users want to return None instead, however , this is not allowed in Django view function, I found  <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.w3.org%2FProtocols%2Frfc2616%2Frfc2616-sec10.html%23sec10\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFNeRNwo63lcJZ54-pKBju_fZUY-Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.w3.org%2FProtocols%2Frfc2616%2Frfc2616-sec10.html%23sec10\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFNeRNwo63lcJZ54-pKBju_fZUY-Q&#39;;return true;">HttpResponse(status=204) may come for rescue in this case,  thus it would be better to include HttpResponse(status=204) as an HttpResponse subclasses for convenience so that could save Django users from asking those returning-null-response questions:
<a href="http://stackoverflow.com/questions/17557618/post-without-response-in-django-javascript-interaction" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F17557618%2Fpost-without-response-in-django-javascript-interaction\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHi5vp1iGUsF8NoNaAyPOmYf3I33A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F17557618%2Fpost-without-response-in-django-javascript-interaction\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHi5vp1iGUsF8NoNaAyPOmYf3I33A&#39;;return true;">http://stackoverflow.com/questions/17557618/post-without-response-in-django-javascript-interaction
<a href="http://stackoverflow.com/questions/2131203/django-no-redirections" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F2131203%2Fdjango-no-redirections\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHoWS6ehm-hr7tVpOyljzGwg1uafA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F2131203%2Fdjango-no-redirections\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHoWS6ehm-hr7tVpOyljzGwg1uafA&#39;;return true;">http://stackoverflow.com/questions/2131203/django-no-redirections
<a href="http://stackoverflow.com/questions/4123155/how-do-i-send-empty-response-in-django-without-templates" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F4123155%2Fhow-do-i-send-empty-response-in-django-without-templates\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHDwf5OXIitLLi3DcW7lFqDIBjf5w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F4123155%2Fhow-do-i-send-empty-response-in-django-without-templates\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHDwf5OXIitLLi3DcW7lFqDIBjf5w&#39;;return true;">http://stackoverflow.com/questions/4123155/how-do-i-send-empty-response-in-django-without-templates

BTW, someone already implemented this feature  here, better to adopt it in Django 
<a href="http://django-extras.readthedocs.io/en/latest/ref/http-response.html" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdjango-extras.readthedocs.io%2Fen%2Flatest%2Fref%2Fhttp-response.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFG24zDO_abKowRk3ju087tkmDj7Q&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdjango-extras.readthedocs.io%2Fen%2Flatest%2Fref%2Fhttp-response.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFG24zDO_abKowRk3ju087tkmDj7Q&#39;;return true;">http://django-extras.readthedocs.io/en/latest/ref/http-response.html

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/2f619780-d6f1-4bce-8d34-40a18b87d798%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [feature request] including HttpResponse(status=204) as an HttpResponse subclasses

Adam Johnson-2
Personally I'd be in favour of adding such classes. It seems against the batteries-included philosophy that Django does not provide all of the standard codes as classes. I can never remember which codes correspond to which response types, if I saw status=204 in code it would be a 'magic number' for me and I'd have to look it up. HttpResponseRedirect and HttpResponsePermanentRedirect have been my friends in the past, I can imagine the same for HttpResponseNoContent. 

On 7 April 2017 at 00:44, Philip Lee <[hidden email]> wrote:
I think you'd better write the decision in the document to stop Django users from making the same feature request in future !

On Thursday, April 6, 2017 at 12:35:41 AM UTC+8, Tim Graham wrote:
Hi, this was already wontfixed here:
https://code.djangoproject.com/ticket/3362

with the rationale, "We've decided in the past not to add a new class for every single response code. You can already pass the status code in when creating the HttpResponse class, so that can be used in this case."

(found with this google search: httpresponse 204 site:code.djangoproject.com)

On Wednesday, April 5, 2017 at 11:25:44 AM UTC-4, Philip Lee wrote:
Every Django view function MUST return an HttpResponse object, sometimes we just want to send data to the server and  don't want to send data back to the client , this probably lead Python users want to return None instead, however , this is not allowed in Django view function, I found  HttpResponse(status=204) may come for rescue in this case,  thus it would be better to include HttpResponse(status=204) as an HttpResponse subclasses for convenience so that could save Django users from asking those returning-null-response questions:
http://stackoverflow.com/questions/17557618/post-without-response-in-django-javascript-interaction
http://stackoverflow.com/questions/2131203/django-no-redirections
http://stackoverflow.com/questions/4123155/how-do-i-send-empty-response-in-django-without-templates

BTW, someone already implemented this feature  here, better to adopt it in Django 
http://django-extras.readthedocs.io/en/latest/ref/http-response.html

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/2f619780-d6f1-4bce-8d34-40a18b87d798%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM3mrxWg4tW6CTYKMCxU4Fsk8Fs55uEVtEN6gR-yAw2QOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [feature request] including HttpResponse(status=204) as an HttpResponse subclasses

Brice PARENT-2

Le 07/04/17 à 08:54, Adam Johnson a écrit :
Personally I'd be in favour of adding such classes. It seems against the batteries-included philosophy that Django does not provide all of the standard codes as classes. I can never remember which codes correspond to which response types, if I saw status=204 in code it would be a 'magic number' for me and I'd have to look it up. HttpResponseRedirect and HttpResponsePermanentRedirect have been my friends in the past, I can imagine the same for HttpResponseNoContent.

+1

And there are more than just HttpResponseRedirect and HttpResponsePermanentRedirect that are provided by now.

In django.http.response, you can find :

HttpResponseRedirect, HttpResponsePermanentRedirect, HttpResponseNotModified, HttpResponseBadRequest, HttpResponseNotFound, HttpResponseForbidden, HttpResponseNotAllowed, HttpResponseGone, HttpResponseServerError

of which 7 don't embed any code, just the status code (like what is asked for 204).

I'm not saying all of them are widely used enough to require an explicit class declaration (like status code 418) or even would mean anything in the context of a web framework, but the most common should, at least, be in the batteries. 204 is an example, but there probably are some others (like 426 and 505, when the world is switching to https).

-OR-

We should at least provide a reversed version of django.http.response.REASON_PHRASES (which doesn't exist anymore, I think), so that we could call :

HttpResponse(status=response_codes.no_content)

It makes it way less cryptic for both the writer and the readers of the code.

-Brice

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/3d69e4e0-0f4a-3f75-3315-3b41c7569ffb%40brice.xyz.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [feature request] including HttpResponse(status=204) as an HttpResponse subclasses

Marc Tamlyn
I would be happy to revisit that decision which was made 9 years ago. APIs returning unusual status codes such as 204 are much more common now than they were then. I can't think of a good reason not to add ~10-15 2-line classes.

Marc

On 7 April 2017 at 09:37, Brice PARENT <[hidden email]> wrote:

Le 07/04/17 à 08:54, Adam Johnson a écrit :
Personally I'd be in favour of adding such classes. It seems against the batteries-included philosophy that Django does not provide all of the standard codes as classes. I can never remember which codes correspond to which response types, if I saw status=204 in code it would be a 'magic number' for me and I'd have to look it up. HttpResponseRedirect and HttpResponsePermanentRedirect have been my friends in the past, I can imagine the same for HttpResponseNoContent.

+1

And there are more than just HttpResponseRedirect and HttpResponsePermanentRedirect that are provided by now.

In django.http.response, you can find :

HttpResponseRedirect, HttpResponsePermanentRedirect, HttpResponseNotModified, HttpResponseBadRequest, HttpResponseNotFound, HttpResponseForbidden, HttpResponseNotAllowed, HttpResponseGone, HttpResponseServerError

of which 7 don't embed any code, just the status code (like what is asked for 204).

I'm not saying all of them are widely used enough to require an explicit class declaration (like status code 418) or even would mean anything in the context of a web framework, but the most common should, at least, be in the batteries. 204 is an example, but there probably are some others (like 426 and 505, when the world is switching to https).

-OR-

We should at least provide a reversed version of django.http.response.REASON_PHRASES (which doesn't exist anymore, I think), so that we could call :

HttpResponse(status=response_codes.no_content)

It makes it way less cryptic for both the writer and the readers of the code.

-Brice

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/3d69e4e0-0f4a-3f75-3315-3b41c7569ffb%40brice.xyz.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMwjO1F6qCBTyVhEN0MbkSh2fHJNt%3DFVyMTmQ%3Dn_Knt23HVPZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [feature request] including HttpResponse(status=204) as an HttpResponse subclasses

Berker Peksağ
In reply to this post by Adam Johnson-2
On Fri, Apr 7, 2017 at 9:54 AM, Adam Johnson <[hidden email]> wrote:
> Personally I'd be in favour of adding such classes. It seems against the
> batteries-included philosophy that Django does not provide all of the
> standard codes as classes. I can never remember which codes correspond to
> which response types, if I saw status=204 in code it would be a 'magic
> number' for me and I'd have to look it up. HttpResponseRedirect and
> HttpResponsePermanentRedirect have been my friends in the past, I can
> imagine the same for HttpResponseNoContent.

Alternatively, they can use the HTTPStatus enum from the stdlib if
they are on Python 3.5+:

    from http import HTTPStatus

    HttpResponse(status=HTTPStatus.NO_CONTENT)

--Berker

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAF4280K-fT8bRnc6fvpZj0RjuhK8b2-eSozMKEJMsPT0EinevQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [feature request] including HttpResponse(status=204) as an HttpResponse subclasses

Adam Johnson-2
I've made a ticket for this: https://code.djangoproject.com/ticket/28469

On 7 April 2017 at 11:18, Berker Peksağ <[hidden email]> wrote:
On Fri, Apr 7, 2017 at 9:54 AM, Adam Johnson <[hidden email]> wrote:
> Personally I'd be in favour of adding such classes. It seems against the
> batteries-included philosophy that Django does not provide all of the
> standard codes as classes. I can never remember which codes correspond to
> which response types, if I saw status=204 in code it would be a 'magic
> number' for me and I'd have to look it up. HttpResponseRedirect and
> HttpResponsePermanentRedirect have been my friends in the past, I can
> imagine the same for HttpResponseNoContent.

Alternatively, they can use the HTTPStatus enum from the stdlib if
they are on Python 3.5+:

    from http import HTTPStatus

    HttpResponse(status=HTTPStatus.NO_CONTENT)

--Berker

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAF4280K-fT8bRnc6fvpZj0RjuhK8b2-eSozMKEJMsPT0EinevQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM2a6c4WEHT_v_cUo0L9Jo6eQA%2B_5T%3DeozB2TX-ph8tXKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [feature request] including HttpResponse(status=204) as an HttpResponse subclasses

Tim Graham-2
I think I prefer documenting Berker's suggestion rather than adding more classes to Django, unless perhaps, they add some additional functionality as HttpResponseNoContent does.

Did you intend to have response subclasses for all
57 values of http.HTTPStatus?

On Sunday, August 6, 2017 at 4:17:22 PM UTC-4, Adam Johnson wrote:
I've made a ticket for this: <a href="https://code.djangoproject.com/ticket/28469" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcode.djangoproject.com%2Fticket%2F28469\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE_-Q5zcv8tFHohILRrfWIIZaoL-w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcode.djangoproject.com%2Fticket%2F28469\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE_-Q5zcv8tFHohILRrfWIIZaoL-w&#39;;return true;">https://code.djangoproject.com/ticket/28469

On 7 April 2017 at 11:18, Berker Peksağ <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="AGu78ywBBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">berker...@...> wrote:
On Fri, Apr 7, 2017 at 9:54 AM, Adam Johnson <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="AGu78ywBBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">m...@...> wrote:
> Personally I'd be in favour of adding such classes. It seems against the
> batteries-included philosophy that Django does not provide all of the
> standard codes as classes. I can never remember which codes correspond to
> which response types, if I saw status=204 in code it would be a 'magic
> number' for me and I'd have to look it up. HttpResponseRedirect and
> HttpResponsePermanentRedirect have been my friends in the past, I can
> imagine the same for HttpResponseNoContent.

Alternatively, they can use the HTTPStatus enum from the stdlib if
they are on Python 3.5+:

    from http import HTTPStatus

    HttpResponse(status=HTTPStatus.NO_CONTENT)

--Berker

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="AGu78ywBBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django-develop...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="AGu78ywBBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django-d...@googlegroups.com.
Visit this group at <a href="https://groups.google.com/group/django-developers" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/group/django-developers&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/django-developers&#39;;return true;">https://groups.google.com/group/django-developers.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/django-developers/CAF4280K-fT8bRnc6fvpZj0RjuhK8b2-eSozMKEJMsPT0EinevQ%40mail.gmail.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-developers/CAF4280K-fT8bRnc6fvpZj0RjuhK8b2-eSozMKEJMsPT0EinevQ%40mail.gmail.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-developers/CAF4280K-fT8bRnc6fvpZj0RjuhK8b2-eSozMKEJMsPT0EinevQ%40mail.gmail.com&#39;;return true;">https://groups.google.com/d/msgid/django-developers/CAF4280K-fT8bRnc6fvpZj0RjuhK8b2-eSozMKEJMsPT0EinevQ%40mail.gmail.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/54f2537f-5c5a-4d3c-99b1-90630bc5b34f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [feature request] including HttpResponse(status=204) as an HttpResponse subclasses

Adam Johnson-2
Did you intend to have response subclasses for all 57 values of http.HTTPStatus?

I hadn't entirely thought it through before implementing :) I agree it's too much, and many are highly unlikely for Django applications to respond with, e.g. 203 Non-Authoritative Information.

I'll document the http.HTTPStatus solution and add only classes that provide extra functionality for Django-app-plausible status codes.

On 7 August 2017 at 16:42, Tim Graham <[hidden email]> wrote:
I think I prefer documenting Berker's suggestion rather than adding more classes to Django, unless perhaps, they add some additional functionality as HttpResponseNoContent does.

Did you intend to have response subclasses for all
57 values of http.HTTPStatus?

On Sunday, August 6, 2017 at 4:17:22 PM UTC-4, Adam Johnson wrote:
I've made a ticket for this: https://code.djangoproject.com/ticket/28469

On 7 April 2017 at 11:18, Berker Peksağ <[hidden email]> wrote:
On Fri, Apr 7, 2017 at 9:54 AM, Adam Johnson <[hidden email]> wrote:
> Personally I'd be in favour of adding such classes. It seems against the
> batteries-included philosophy that Django does not provide all of the
> standard codes as classes. I can never remember which codes correspond to
> which response types, if I saw status=204 in code it would be a 'magic
> number' for me and I'd have to look it up. HttpResponseRedirect and
> HttpResponsePermanentRedirect have been my friends in the past, I can
> imagine the same for HttpResponseNoContent.

Alternatively, they can use the HTTPStatus enum from the stdlib if
they are on Python 3.5+:

    from http import HTTPStatus

    HttpResponse(status=HTTPStatus.NO_CONTENT)

--Berker

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAF4280K-fT8bRnc6fvpZj0RjuhK8b2-eSozMKEJMsPT0EinevQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/54f2537f-5c5a-4d3c-99b1-90630bc5b34f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM1Tf8z8BPQnk1Rw9FBuhGNgXmi2RDodH%2BiSdodqYTpJdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.