
Django Ninja Has a Free API — FastAPI-Style Endpoints in Django
Django Ninja brings FastAPI-style API development to Django. Type hints, automatic validation, OpenAPI docs — all running on Django's battle-tested ORM and middleware. Why Django Ninja? FastAPI is great but doesn't have Django's ORM, admin, auth, or migrations. Django REST Framework is powerful but verbose. Django Ninja gives you the best of both worlds. Quick Start pip install django-ninja # api.py from ninja import NinjaAPI api = NinjaAPI () @api.get ( ' /hello ' ) def hello ( request , name : str = ' World ' ): return { ' message ' : f ' Hello, { name } ! ' } # urls.py from django.urls import path from .api import api urlpatterns = [ path ( ' api/ ' , api . urls ), ] That's it. Visit /api/docs for Swagger UI. Schema Validation with Pydantic from ninja import Schema from datetime import datetime class PostIn ( Schema ): title : str content : str tags : list [ str ] = [] class PostOut ( Schema ): id : int title : str content : str created : datetime @api.post ( ' /posts ' , response =
Continue reading on Dev.to Python
Opens in a new tab



