Moving rest_framework.status into core?

84 views
Skip to first unread message

Carlton Gibson

unread,
Mar 23, 2021, 11:18:19 AM3/23/21
to Django developers (Contributions to Django itself)
Hiya. 

Maybe my search-foo is down but, surprisingly, I couldn't find a discussion on this. 

Should we maybe bring the HTTP status code constants that we find in rest_framework.status into core, as django.http.status? 

I find myself wanting them (not for the first time) in a project that doesn't really depend on DRF, and thinking (surely) these fit comfortably in Django's "I'm a web framework" remit. 🤔

Can I solicit opinions on that please? It's just a list of constants so... 
It seems to fit the "bring some of the more reusable bits of DRF into core" theme. 

Thanks. 

Kind regards, 
Carlton

Adam Johnson

unread,
Mar 23, 2021, 11:24:41 AM3/23/21
to django-d...@googlegroups.com
Python 3.5 added http.HTTPStatus: https://docs.python.org/3.9/library/http.html#http.HTTPStatus , so I don't see a need for such constants in Django, unless they add something extra. Perhaps you could deprecate from DRF.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/541cf57b-f369-4dc9-a06e-e3ff8bf4485cn%40googlegroups.com.


--
Adam

Arthur Rio

unread,
Mar 23, 2021, 12:04:01 PM3/23/21
to django-d...@googlegroups.com
The one thing that I really prefer from DRF's statuses is their name, containing the status_code. I used python's `http.HTTPStatus` in a flask project and I had to have the python docs open
all the time to map between the status code and the name of the status. For example: 
- http.HTTPStatus.BAD_GATEWAY
- rest_framework.status.HTTP_502_BAD_GATEWAY

I don't know if it's enough of an argument to justify maintaining extra code in Django, but as Carlton said, it's just a file with constants. If you look at the file in DRF, there haven been very little changes to it
https://github.com/encode/django-rest-framework/commits/master/rest_framework/status.py and in my opinion, it does make the developer experience nicer.

Best,

Arthur
Reply all
Reply to author
Forward
0 new messages