I have a simple view in which I\'m saving a form. The code seems \'clean\', but I can\'t get rid of the error:
"The view didn\'t return an HttpRespo
If you are using the Django Rest framework. Use the below code to return the HTTP response to resolve this issue.
from django.http import HttpResponse
def TestAPI(request):
# some logic
return HttpResponse('Hello')
JSON Response return example:
def TestAPI(request):
your_json = [{'key1': value, 'key2': value}]
return HttpResponse(your_json, 'application/json')
For more details about HttpResponse: https://docs.djangoproject.com/en/3.1/ref/request-response/#django.http.HttpResponse