Django creating an API

Hello. Instead of using something like Django rest framework, can you use regular Django to develop an API? If so is it as efficient as using something like Django rest framework? Or is rest framework more efficient and quicker when developing APIS with Django? Thanks

Yes you can. Django Rest Framework (DRF) is “just” an add-in to Django. (I put the “just” in quotes because it’s really a fantastic package and really could be thought of as an entire subsystem that extends the base system.)

I would say that for a smaller application, the benefits of going with DRF are correspondingly smaller. But as your needs / models / interfaces grow and become more complex, that’s when you would start seeing more of the benefits.

If you haven’t already done so, spend some time with the DRF documentation, particularly the API Guide list of entries to see everything that it provides. Then think about which of those you would find useful and how much time you’d spend needing to recreate that functionality.

So yea, if I just needed to expose one model to generate one type of response, I’d probably write a function-based view returning JsonResponse objects and call it a day.

But if I’ve got a couple-hundred models with dozens of foreign key relationships, I’m almost definitely going to make a different decision.


@KenWhitesell Thanks,

I’m concerned about how well known it is. It seems not very popular or used by many companies however I may be wrong.

What’s your take on this? Also would you consider DRF it’s own seperate thing with its own conventions different to Django, and not supporting things like Django channels or async stuff?

Or would you see it as just an addition to Django whilst following its conventions, whilst having all the features Django already has ( examples mentioned above). Thanks

Ok, now we’re really going off the rails into speculation territory here…


Looking at the github stats:

  • Django
    • Used by 421k, Star 49.7k
  • DRF
    • Used by 122k, Star 17.7k

Seems to me like there’s a very sizable percentage of Django users interested in it on github. DRF also has its own funding model which appears to be working well enough to keep it going.

My guess is that it’s not as “obviously popular” as Django is because it’s generally used behind the scenes and might not get the publicity as some of the other components do. (Also because it is a Django app and not an independent component, some may just consider it part of Django.)

I’ve always looked at DRF as a “beefed-up” way of writing views returning JsonResponse objects in the same way you might look at the generic CBVs or CrispyForms as enhanced ways of returning HttpReponse objects. (The parallel isn’t perfect, but I think it’s good enough for this discussion.) Assuming the level of interest remains as high as it has been, my guess would be that DRF has a long life ahead of it.

Great this helps a lot thanks