Home > Blockchain >  Is it important to include status in Django?
Is it important to include status in Django?

Time:07-18

I am working on project where I'm importing, parsing and showing JSON data on site. I wanted to ask if it's important to add in JsonResponse "status" attribute.

For example: return JsonResponse({"details":"Data parsed successfully!"}, safe=False, status=200)

Thanks!

CodePudding user response:

Yes, it is pretty much important. It might seem useless at the beginning, but it shows that you actually control what is happening and you can predict what can go wrong (actually most important!).

Status codes are universal and usually give fast feedback what went wrong without any further information. It's good practice to always add status to response that is sent from your application.

  • Related