[Answered ]-Django REST API: How to respond to POST request?

1👍

just add a return in the view … like this:

class get_post(View):
    def post(self, request):
        if request.method == 'POST':
            return JsonResponse({"response": 'got post request'}, safe=False)

because the error complains that the post function must return anything.

for the second question ya you need to return JsonResponse because you are dealing with APIs.

Leave a comment