top | item 42715061

(no title)

ryannevius | 1 year ago

We use Django and django-ninja [1] and like it MUCH better than DRF.

[1] https://django-ninja.dev

discuss

order

bkovacev|1 year ago

Care to elaborate further? I keep reading on this, but no one actually mentions anything specific that ninja does better than DRF.

godtoldmetodoit|1 year ago

The main benefit most people see right away is the Pydantic integration & it requires less boiler plate for basic API's. Ninja is essentially FastAPI + Django.

I prefer Ninja over DRF, but I know plenty of orgs who still love their class based DRF views as once you are over the (significant) mental hurdle of understanding all the abstraction there, it does give you the common CRUD type operations on your models "for free".

winrid|1 year ago

DRF has more abstraction. When I was new to Django I found DRF hard to build a larger API with it and not make mistakes or have things get confusing. You're primarily working by extending classes etc.

With django-ninja you just define your APIs with annotated types as methods, there is no magic, and then you get a generated OpenAPI spec.

this was my experience anyway, I used DRF for this project [0] and ninja for this one [1]

[0] https://govscent.org/api/

[1] https://sidewaysdata.com/api/docs

anentropic|1 year ago

I haven't used django-ninja but to me it looks like the API is a bit nicer or more 'modern' looking (i.e. declarative via type annotations) and it's faster, both due to being based on Pydantic

DRF is old and API looks more like Django forms or class-based views, more of an OOP hierarchy going on, and DRF serializers are slow