top | item 44559640

(no title)

Euphorbium | 7 months ago

Fastapi has completely replaced django for me. I do not miss orm at all.

discuss

order

lutoma|7 months ago

I’ve also switched away from Django (to Litestar), but the ORM is the mean thing I keep missing from Django. SQLAlchemy feels really clunky by comparison

rollcat|7 months ago

I think the ORM is fine. There's always some friction coming from mapping rows to classes and objects, but you can always drop down a layer and just pull raw tuples.

What I'm not a fan of, is the query DSL. Normally, the developer works to figure out how to express their problem with SQL; then the DB engine works to figure out how to map that SQL to the data it has on disk. Now Django adds another layer, which is completely unlike SQL, has its own unique pitfalls, etc; sometimes I find myself just dumping the raw SQL, working on that to get the result I wanted, then working that back to the DSL.

I think SQLAlchemy gets it right. The query language is a thin veil over SQL, and mapping to objects is an explicit and clear operation. What does feel clunky to me, is setup: SQLAlchemy expects you to bring your own glue; Django is vertically integrated.

sparkling|7 months ago

What made you choose Litestar over fastapi (which seems to be the most popular choice right now)?

Takennickname|7 months ago

"If you're not using Django, you're probably just rebuilding it poorly."

drdaeman|7 months ago

I think FastAPI's one major design difference is its dependency injection mechanism. Django is designed to do things differently, with services provided through an app- or project-global collection of middlewares (although I haven't used it in a while, maybe something had changed since then) and while there are DI solutions for Django they don't feel "native" to me - not the way FastAPI does it. Either way works, of course - it's probably merely a matter of the preferred mental model.

mushufasa|7 months ago

Django-ninja is a combination of Django with fastapi.