'[Litestar is] not aiming to be “the next Django”' and a temperature check #2257
Replies: 4 comments 6 replies
-
It's great to read the above and a very extensive write-up! We don't aim to be the next Django because Django is, first and foremost, an MVC framework. As you know, this is an older generation of frameworks that tried to offer a complete solution for server-side rendering websites and thus became huge. We are an API / Web framework - or as you call it, HyperMedia application framework- but we will not be an MVC framework. First, we do not follow the MVC pattern in the design, and second, we do not seek to offer the tight coupling with ORM logic that Django and some other older frameworks have. From the features you mention -
The rest of the stuff has yet to be discussed or planned. An Admin Site, for example, is excessive for us. It could be a great 3rd party package or even an extra package by our org - but not a part of the library itself. Saying that, our roadmap is in constant discussion - but we decided (following @provinzkraut's lead) that for the time being, we will slow down the expansion of new features for now and focus on polishing and fixing issues, making stability the primary concern. We want to be like Django to the degree we create something of the highest quality on which you can build and count. That is, we want Litestar to be a first-grade production framework trusted by developers and companies - like Django. |
Beta Was this translation helpful? Give feedback.
-
Sure, I'll give my opinion. We have DTOs - these are different from "Models" in MVC. DTOs come from the Java world (initially) and are simply objects for the serialization and deserialization (or, in general - transmission) of data. Whereas "Models" are usually a representation of structured data, such as (classically) a database table row. To follow the MVC pattern used by such frameworks as Django and Rails, the application must be tightly coupled to a database, or if we are talking in a more abstract sense - a persistent and semi-structured state. The "Controller" in MVC is a layer of control and manipulation of data akin to a repository or a "CRUD controller." We don't have that at the moment, although there is this draft PR I'm working on: #2245, which will add this for data APIs and will allow for easy integration with HTML / HTMX. As for "View" - this part we do have. Views send a representation of the result of the operation performed on data and are thus conducive to "Hypermedia Applications." You can quickly render HTML using Litestar and create a view like this, be it using a templating engine or HTMX.
I agree with you here. One commenter on a LinkedIn post of mine pointed out that I should not call Litestar an "API framework" because it is a "Web framework". I must confess that a better terminology eludes me, so perhaps "web framework" is the correct phrase. |
Beta Was this translation helpful? Give feedback.
-
Lol, what?
Yes, not difficult at all - and in fact some of our examples like the "fullstack" example basically do this. The point is merely that we are not going to couple the ORM to a degree that establishes this architecture from the get go.
Fair enough. In the end we are somewhere in the "fullstack" realm I think. |
Beta Was this translation helpful? Give feedback.
-
Cool. I was surprised - frugenwaffle sounds so very German, which is a language I speak, and yet it is completely meaningless 😉 |
Beta Was this translation helpful? Give feedback.
-
Intro and Background
Me
Hello all. I am a engineering manager and engineer that cares a lot about Python and avoiding complexity / over-engineering. To that end, have been on a crusade over the last couple years to promote hypermedia driven applications (HDAs), as I think that they solve many (self inflicted) problems that have plagued web development for the last decade or so.
PyHAT
At PyCon 2023, @tataraba and I conceived of a web stack (a la LAMP, MEAN, MERN, etc) called PyHAT: Python, HTMX (or hypermedia), ASGI, Tailwind. I have spend a lot of time looking at what the state of the art is for Hypermedia driven applications are in Python, and came to the conclusion that Django has by far the biggest community around creating HDAs.
Python Microframeworks
My experience and understanding is that Python microframeworks (FastAPI, Starlette, Flask/Quart, etc) are almost exclusively used to create JSON API's to drive SPAs, rather than HDAs. I have tried to create a HDA using FastAPI and found that:
This is a problem that I discussed with @tataraba at length. We both agree (IIRC) that Python microframeworks tend to require a lot of boilerplate / reinventing the wheel to make a HDA, but there is really only one alternative to that within the Python ecosystem, which brings us to:
Django
Django is basically built to make HDAs, but there are other problems with Django. I have my own list of issues with Django (which has only grown since writing this), as does @tataraba.
That said, I was still pretty convinced that Django was the best option for building an HDA with Python today. @tataraba and I had discussed that it would be great, and there is likely a market for, a spiritual successor to Django. What would it look like if Django was invented today?
Things that I would think would look different:
Things that I think would stay the same (more or less):
manage.py
(not necessarily exactly in the same form, but an opinionated, common cli interface for common chores)My Introduction to Litestar
I became dissolutioned with FastAPI relatively early on, mostly around the project's governance but also due to it's poor support for anything other than JSON-slinging, and heard about Litestar (then Starlite) being framed as "FastAPI but without a bus factor of one". I thought this was great, but it didn't really solve the "Python microframeworks are designed and used to feed JSON to React" problem, so I didn't spend much time looking into Starlite.
That was a couple years ago. Fast forward to a few weeks ago and I got a ping to add Litestar to add it to my Awesome list. The last week or so I have been looking into Litestar, how people are using it, what features it has, etc.
And what do you know, Litestar checks.. a lot of the boxes for the things that I would have wanted from "Django designed in 2023". It is actually easier to go over the things it doesn't do:
(I am still learning what Litestar has to offer, so take the following with a grain of salt)
manage.py
equivalentThis is.. really impressive. And really exciting. So that begs the question then:
What Does '[Litestar is] not aiming to be “the next Django”' Mean?
The example given in the docs is that Litestar will not "have it's own ORM", but IMO what makes Django what it is is not that it has it's own bespoke ORM, (or templating library, or testing system 🙄) it's that it's opinionated, batteries included, has a strong community, and has a focus on HDAs. It seems to me that Litestar already has most if not all of these things!
The Missing Features / Batteries
I'm sure that none of the things listed above are novel things to be brought up, so forgive me. I'm curious what the maintainers think about including in Litestar's scope the following:
manage.py
equivalent (maybe https://docs.litestar.dev/latest/usage/cli.html already covers this?)Misc Observations
There are some other things that I think make Litestar a better, more modern alternative to Django (as opposed to "just" being an alternative to FastAPI, which I think is what the perception is):
Litestar should consider pivoting it's marketing towards HDA's / being an alternative to Django. Not saying it shouldn't also hold itself out as an alternative to just FastAPI. The first paragraph says "focused on building APIs". Am I way off base here in my thinking?
PyHAT
I have been wanting to make an example PyHAT project for some time, and had actually started with Django, but I think Litestar would be a better fit at this point.
Closing Thoughts
I'm super impressed overall. I hope that nothing above comes off as critical or negative. If you got this far thanks for your time and consideration!
Beta Was this translation helpful? Give feedback.
All reactions