FastAPI has become a very popular choice for building APIs in Python. It's modern, fast and has an excellent DX. But when a project grows (ORM, admin, auth, forms, migrations), you end up chaining external libraries together. Django gives you all of that out of the box.

In this post, we talk about why having "batteries included" boosts your productivity without giving up on modern tooling.

FastAPI and the Python ecosystem

FastAPI has gained a lot of traction, and for good reason: it's ideal for APIs, microservices and scenarios where performance matters. Its type-hint syntax, automatic OpenAPI generation and the performance it gets from Starlette and Pydantic make it a fantastic option.

But a real project is rarely just an API. Soon you need an ORM, a migration system, authentication, an admin panel, forms with validation, tests... and you start chaining libraries together:

You need FastAPI (external libraries) Django (built in)
ORM + Migrations SQLAlchemy + Alembic django.db.models + makemigrations
Admin panel Flask-Admin, SQLAdmin or custom django.contrib.admin
Auth (users, sessions, permissions) python-jose + passlib + fastapi-users django.contrib.auth
Forms with validation Build it manually with Pydantic django.forms
Tests httpx + pytest-asyncio Built-in test client
Internationalization Babel + custom gettext + built-in middleware

Of course, SQLAlchemy is powerful and pytest-asyncio works great. But every time you set up a new project, you have to make the same decisions over and over again. Django already made them for you, and they've been working since 2005.

What does "batteries included" mean?

Django was born at a digital newspaper (Lawrence Journal-World) with a clear premise: building web applications should be fast and fun. Its motto, "The web framework for perfectionists with deadlines," is no accident.

Batteries included means you can go from zero to a working project with an admin, a database and authentication in a matter of minutes:

django-admin startproject my_project
cd my_project
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver

With those five commands you have a website up and running, with a database ready and an admin panel at http://localhost:8000/admin/, without installing anything else.

Is Django still modern?

This is the question we hear most often. Django has evolved a great deal and hasn't been left behind in the async era:

  • Django 3.0: ASGI support and async views.
  • Django 5.0: generated fields and database performance improvements.
  • Django 5.2 LTS / 6.0: a mature async ORM and full compatibility with Python 3.13+.

Async support in the ORM improves with every release: each version expands coverage with new a* variants (aget, aexists, acount, acreate...), and the Django team aims for full parity with the synchronous API. The direction is clear and the pace is steady.

And for cases where you need to cross the boundary between the two worlds (calling synchronous code from a coroutine or vice versa), Django ships with asgiref and its sync_to_async and async_to_sync utilities:

from asgiref.sync import sync_to_async

# Wrap a synchronous function so it can be used in an async context
get_projects = sync_to_async(Project.objects.filter(active=True).all)
projects = await get_projects()

There's nothing to install: asgiref already comes as a Django dependency.

Today you can write async views and interact with the database without blocking the event loop by using the ORM's native functions:

# views.py
from django.http import JsonResponse
from .models import Project

async def my_endpoint(request):
    # Native async queries in the ORM (acount, afirst, afilter...)
    total_projects = await Project.objects.acount()  
    return JsonResponse({"projects_in_system": total_projects, "message": "Native async Django!"})

And when you need to build a REST API, you have two great paths:

  1. Django REST Framework (DRF), the classic de facto standard.
  2. Django Ninja, the modern alternative, 100% inspired by FastAPI (type hints, Pydantic and automatic OpenAPI).

With Django Ninja, going from a model to an endpoint with validation and automatic interactive documentation is as clean as this:

# ninja_api.py
from ninja import NinjaAPI, ModelSchema
from .models import Project

api = NinjaAPI()

class ProjectOut(ModelSchema):
    class Meta:
        model = Project
        fields = ['id', 'name', 'technology']

@api.get("/projects", response=list[ProjectOut])
def list_projects(request):
    return Project.objects.all()

Django as a pure backend

Just as you can ignore the synchronous side of FastAPI and use only async SQLAlchemy, in Django you can ignore templates, admin and forms if your goal is to serve an API. The ORM, authentication, migrations and tests are still there, working, and you decide which parts to use.

Django + Ninja or Django + DRF is a pure backend, exactly like FastAPI + SQLAlchemy.

Same endpoint, two approaches

Let's look at a real example comparing the setup of a GET /projects/ endpoint that returns a list using async tools in both worlds.

FastAPI

from sqlalchemy import select
from fastapi import FastAPI, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from database import get_session, Project as ProjectModel
from schemas import ProjectOut

app = FastAPI()

@app.get("/projects")
async def list_projects(session: AsyncSession = Depends(get_session)):
    result = await session.execute(select(ProjectModel))
    projects = result.scalars().all()
    return [ProjectOut.model_validate(p) for p in projects]

Django + Ninja

from ninja import NinjaAPI, ModelSchema
from .models import Project

api = NinjaAPI()

class ProjectOut(ModelSchema):
    class Meta:
        model = Project
        fields = ['id', 'name', 'technology']

@api.get("/projects", response=list[ProjectOut])
async def list_projects(request):
    return [project async for project in Project.objects.all()]

With no need to manually configure database sessions, redundant dependency injectors or endless imports, Django already knows how to connect to the database, how to map the models and how to manage the lifecycle of the request.

When you have 20 models, 50 endpoints and a team of several people, the boilerplate you save thanks to this unified structure shows up in your day-to-day work.

What about performance?

The general perception is that Django is slow compared to FastAPI, and that's true if you compare a bare-bones FastAPI against Django with admin, sessions, middleware and everything turned on, but that's not a fair comparison.

If your project needs an ORM, migrations, authentication, validation and tests, FastAPI on its own isn't enough. You add SQLAlchemy, Alembic, Pydantic, fastapi-users, httpx, pytest-asyncio... and that whole stack also has its cost in memory and response time. In a real benchmark with all those libraries included, the difference between Django and FastAPI is much smaller than people think and, in many cases, marginal.

Besides, thanks to Django's mature async ecosystem, you're no longer giving up concurrency or speed for I/O-intensive operations.

The question isn't "which framework is faster?" but "how much time and effort does each one save you for the real needs of your project?".

When to use Django and when to use FastAPI?

Situation Recommendation
Pure API, isolated microservice, very high raw performance FastAPI
Pure API that needs a powerful ORM, a migration system and built-in tests Django + Ninja / DRF
Web application with a dashboard, internal admin and full user management Django
An MVP that needs to go to production within weeks Django (free admin)
API + web application (monolith) in the same project Django
You want to learn a robust framework with industry-standard practices Django

Conclusion

Django isn't FastAPI's enemy, it's its natural alternative or complement, depending on the scale of what you're building. When your project needs more than just serving JSON, having the ORM, admin, authentication and migrations natively integrated makes a huge difference in productivity.

If you've only used FastAPI, I invite you to try Django on your next side project or MVP using Django Ninja. Batteries included doesn't mean heavy, it means you don't have to worry about what's already solved.

Tell us what you think.

Comments are moderated and will only be visible if they add to the discussion in a constructive way. If you disagree with a point, please, be polite.