Technical
FastAPI vs Django: Choosing the Right Python Framework
A developer on my team asked whether we should use FastAPI or Django for a new project. The answer, like most architecture decisions, depends entirely on what you are building and who will maintain it after you ship.
When FastAPI Wins
FastAPI is my default for API-first projects. If your backend serves a frontend application (React, Next.js, or a mobile app) and the frontend handles all the UI rendering, FastAPI is almost always the right choice.
Why FastAPI for APIs:
- Type-safe by default: Pydantic models validate every request and response automatically
- Auto-generated docs: OpenAPI spec from your code, no extra work or configuration
- Lightweight: Only install what you need. No ORM, no admin panel, no template engine
- Async native: Built on Starlette, handles concurrent requests efficiently
# FastAPI: an entire API endpoint in 5 lines
@app.post('/posts', status_code=201)
async def create_post(post: PostCreate) -> PostResponse:
item = save_to_database(post)
return item_to_response(item)When Django Wins
Django is my choice for admin-heavy applications. If non-technical users need to manage data through a web interface, Django's built-in admin panel saves weeks of development time.
Why Django for admin apps:
- Admin panel: Built-in CRUD interface for every model with search, filters, and bulk actions
- ORM: Database migrations, relationships, and queries without writing SQL
- Batteries included: Auth, sessions, forms, file uploads, caching all built in
- Ecosystem: Thousands of packages for every common need (DRF, Celery, django-allauth)
# Django: define a model, get an admin interface for free
class Post(models.Model):
title = models.CharField(max_length=200)
body = models.TextField()
status = models.CharField(choices=STATUS_CHOICES)
admin.site.register(Post)The Decision Framework
| Factor | FastAPI | Django | |--------|---------|--------| | API-only backend | Best choice | Overkill | | Admin interface needed | Build it yourself | Built-in | | Database migrations | Manual via Alembic | Built-in | | Learning curve | Low | Medium | | Async support | Native | Partial (Django 4.1+) | | Project size | Small to medium | Medium to large |
My Real-World Split
Here is how I choose in practice:
- PLAI blog platform: FastAPI because the API serves a Next.js frontend
- Client CRM projects: Django because the admin panel handles data management
- Automation scripts: Neither. Plain Python with urllib and the standard library
The Wrong Question
'Which framework is better?' is the wrong question. The right question is: 'What does my project need?' Start from the requirements, map them to framework strengths, and choose accordingly. The technology should serve the project, not the other way around.
See the FastAPI documentation and Django documentation for detailed getting-started guides.
RELATED READING
The Consulting Shift I Am Making In Year Two
After a year of writing and building, my consulting practice is changing shape. Shorter engagements. Sharper outcomes.
ReadThe Frontend Shift: Shipping Less JavaScript In Year Two
A year ago I reached for Next.js for everything. This year I often reach for nothing.
ReadThe Serverless Lesson I Would Write On A Sticky Note
After a year of shipping serverless projects, one rule explains most of the wins and all of the losses.
Read