How to build a json REST API in django (without Django REST framework)

You can write GET API using this method, but for POST method this will not work. For Post method we need to use some REST Library.

POST Method will check for CSRF token in the cookies and where it fails to execute the request, as your django server will treat this request as forged.


After more googling, I found what I was looking for in the Django docs: JsonResponse

from django.http import JsonResponse
return JsonResponse({'foo':'bar'})

I think googling using the word "REST" was kind of a red herring which made the search space always direct my queries towards "Django REST framework" which is not what I wanted, though I do want to add a RESTful API.