According to the documentation for Django REST Framework, "using bare status codes in your responses isn't recommended". They recommend instead using the objects from the status module (e.g. status.HTTP_404_NOT_FOUND). My question is, where does this recommendation come from? I wasn't able to find any kind of 'official' source for this recommendation.
-
1Probably just because of magic numbers.deceze– deceze ♦2023-06-19 07:22:17 +00:00Commented Jun 19, 2023 at 7:22
Add a comment
|
1 Answer
The recommendation comes from that document but it's based on concepts like avoiding magic numbers.
With the way these statuses are named in Django Rest Framework (source) makes it easier for the developer reading the code to understand and remember what the code represents rather than having to remember or double check what each number refers to.