Hacker News new | ask | show | jobs
by simonw 793 days ago
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/

2 comments

Me too, I'm convinced it has a place - the number of single file projects over the past few years can't be a coincidence.

For me the two missing pieces were models and a path to migrate to a full project once it outgrew a single file, so I wrote nanodjango (https://github.com/radiac/nanodjango/, formerly django-flasky) - you can use the ORM and admin site, and I recently added a "convert" command to automatically break up a single page app into a full Django project structure.

I've been using it for a couple of years for prototyping/experimenting and putting together small apps, and with the new features this year feels like it's a really practical alternative to flask.

> I'm convinced it has a place - the number of single file projects over the past few years can't be a coincidence.

The human soul yearns for the simplicity of php or cgi-bin hosting, without the horrors of PHP or C

Mine certainly does - we lost so much when we killed off our cgi-bin/guestbook.pl
This looks really cool, congratulations.

Are you planning to add some kind of API serving functionality (either by integrating something like Django Ninja or even raw Pydantic)? I think such single file frameworks are great candidates to implement microservices.

Thanks! Yes definitely, I think it's a great fit for anything self-contained and limited scope that doesn't need a lot of code. I've certainly found having an easy way to run a single file using Django's ORM is pretty handy.

Regarding API serving, I'm planning on making it easier to use third party apps; the main obstacle is registering `includes` urls, which is doable at the moment but involves manually appending a path to `nanodjango.urls.urlpatterns`. I want to expand route registration to give a nicer internal api, then once that's in place Django Ninja should work pretty much out of the box - the only different should be how you register the url.

This looks amazing ! Bravo
Thank you, it's great to have positive feedback!
I would be interested to hear your thoughts on why this never ended up going anywhere? (Or did it go somewhere ?)

As a Django user that shares your frustrations with settings.py, I wish this had panned out.

I got very busy at work, then quit to go on honeymoon, then accidentally started a startup!

I wasn't particularly good at sticking with open source projects like this and pushing them forwards back in 2009. I've since learned how to do that but it took me another decade to get there.

Is this something you think you would ever come back to?
Honestly no - not at this point. I have too many other projects on the go. I'd love to see the Django community take this on generally - there are a bunch of people interested in it, hopefully that result in a long-term stable project around the idea.