Search code examples
djangoapidjango-rest-frameworknext.jsdjango-middleware

Django API without DRF: What are the consequences


I'm not sure what might go wrong when I have to integrate a django API (built using JsonResponse and without extra frameworks) with a frontend, in this case, Next.js.

I built a django API using JsonResponse (void of DRF). I want to build a frontend client with Next.js that would make API calls to my django API. My questions are:

  • Will I have to run both django and next.js servers at the same time to execute the full project?
  • I think I would face some challenge with csrf token, what other challenges may I face having built my API without an API framework as Django Rest Framework?

Solution

    1. It is almost always a better approach to treat these two as separated as possible. I'd go with completely separate repos, hosting etc...

    2. I think the biggest advantage of using DRF is the validation. DRF has nice ways to handle request data validation. Your views will look much leaner, because it will save you the trouble of writing much boilerplate code.