> ~ biozz / Blog

Django still rocks 2024-02-14

An overview of full-stack approaches in Python web frameworks

Reading time: 2m (368 words)

A cropped image of a rock formation in the desert with mountains in the background by NEOM from Unsplash.com A cropped image of a rock formation in the desert with mountains in the background by NEOM from Unsplash.com

I have recently been trying to do the things I usually do in Go but with Python, after finding out about Pocketbase. Pocketbase is actually really cool, because it has models with migrations, API and realtime interfaces, while also having a couple of SDKs. There is nothing like that in Python …except there is Django!

If you look at FastAPI and tiangolo/full-stack-fastapi-postgresql you would probably get lost in the amount of docker and docker-compose files. The same goes for all the other popular Python non-full-stack frameworks, that try to add full-stack features to them (e.g. litestar-fullstack).

Next up are ORMs. You have a lot of choices here too. Honourable mentions are: sqlalchemy, peewee and pony. SQLAlchemy is quite big for smaller pet-projects, peewee struggles with async, the same goes to pony. If you want migrations, you use alembic or peewee migrations with a bunch of other packages, or pony migrations. But you also want pydantic for your models, so you end up doing abstractions and interfaces or use something smart people have developed (sqlmodel, which is actually a wrapper around sqlalchemy and you still need alembic for migrations).

You may also need an admin interface to explore your database. Again, you are “lucky”, because there are a number of packages for almost any combination of ORMs and frameworks. I will not list them here, but you get the point: it will be a pain.

And that brings me back to the original point of this post: Django has it all and it just works. Eventually the Django-team will add full async ORM support and it will probably be on par with other frameworks in terms of usability and speed.

If I had to criticise Django, I would say that the settings are the least intuitive. I am also not a fan of the apps framework, as reusable are usually not usable in real life, in my opinion. In my attempts to simplify these things, I went to an extreme and tried to reduce Django to a single file, you can read about that in my previous blog post here.

Still, I would highly recommend using Django if you think you will need a database for your future app.