DRF Response VS Django - JSONResponse

from rest_framework.response import Response
from django.http import JsonResponse

What is the difference between these two? how can I decide which one should I use?

If you are already using DRF, you should use DRF's own Response class.

While both classes will accept python primitives, there are some differences in what they will do craft a response, the biggest being that DRF Response is not bound to a JSON response. A different renderer can be passed to force a different response type, and if supported, a client could use the "Accept" header to request a different response type (e.g. CSV).

The bigger question, whether to use DRF at all or just plain old Django to create an API, that entirely depends on what the scope of your project is.

Back to Top