by simonw on 4/24/2024, 4:52:55 AM
by sireat on 4/24/2024, 6:01:29 AM
Fantastic idea to start Django with a single file!
Some years back when I had to do some quick and dirty projects, I chose to go with Flask because of how dirt simple it was to start.
All the Django books and tutorials had this hidden magic abstraction feel to them after:
$ django-admin startproject <project-name> .
$ python manage.py startapp <app-name>
Once you've reinvented half the Django functionality in Flask (using SQLAlchemy etc) you realize the need for the most of these abstractions.by Onavo on 4/24/2024, 4:53:19 AM
The most powerful part of Django is its ORM, nothing else comes close in the ecosystem. The automatic migration generation tools for SQLAlchemy like alembic are much harder to use than django's built-ins.
Django just needs to add Pydantic integration.
by whatever1 on 4/24/2024, 5:51:27 AM
I really love Django. I knew nothing about web development, it took me by the hand and from a tutorial I went to a full fledged application.
I cannot fathom what is the GDP impact that these folks enabled.
by jarpineh on 4/24/2024, 9:11:55 AM
I'd love to use Django as a fast and easy single file app. There's some great looking solutions here. Have to take a look.
I tried myself about five years ago. My idea was to make a tool that could make a HTTP service from any Python file with very simple setup. With all the features of Django at the ready. Unfortunately neither Django's configuration system nor Python import methods made it reliable enough. Or I just couldn't hack it. This was the smallest I managed:
from django.urls import path
from django.http import HttpResponse
CONF = {
"INSTALLED_APPS": ["serverless"],
"ROOT_URLCONF": (path("", lambda x: HttpResponse("look ma, no server")),),
"DEBUG": True,
"SECRET_KEY": "randobrando"
}
Other thing I tried to do with this was attach a Jupyter kernel. This way I could change the code as I went, but wouldn't have to use entire Jupyter client stuff. Unfortunately there I ran into problems with event loops. I could not find a way to manage different servers in the same runtime instance. Perhaps it's time to try again wiser and helped by LLMs...by wilsonfiifi on 4/24/2024, 6:19:08 AM
Lightweight Django (2014) [0] actually explores using the Django framework in a similar manner.
[0] https://www.oreilly.com/library/view/lightweight-django/9781...
by seper8 on 4/24/2024, 6:21:00 AM
Am I missing something or is there no sample code...?
by thedeparted_one on 4/24/2024, 6:53:48 AM
Awesome!
by xcdzvyn on 4/24/2024, 7:04:56 AM
I really wish there were something like this for Phoenix. I want to like it, but I feel a little inundated with all the codegen.
I'm a big fan of the single-file Django ambition - it's the feature I most envy from frameworks like Flask and Starlette.
I actually had a go at this myself 15 years ago, with a project I called Djng: https://github.com/simonw/djng - more details on that here: https://simonwillison.net/2009/May/19/djng/