2

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.

1
  • 1
    Probably just because of magic numbers. Commented Jun 19, 2023 at 7:22

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.