Open radiac opened 1 month ago
Thinking about this more, this may make more sense as a separate project. It's definitely something I still want, but it feels like more of an edge case than mainstream, and I'm trying to be mindful of not letting nanodjango get too fat (see #35). It may require an extension of the convert
plugin system, or swapping to pluggy.
It could still be installed as a dependency with nanodjango[staticsite]
, but I'm not sure about it as that would mean installing it with nanodjango[all]
. I'm thinking about the learning journey someone's going to go on - once they land on the docs page about creating a static site, it's just as easy to say "now pip install something-else
" as it is "I hope you installed with pip install nanodjango[all]
"
An additional thought - one of the big problems with this idea is needing to commit the database. Alex Kerney pointed out the yamldl project, which may be a good solution.
Add a command to build a static site from your script.
I don't want to overload nanodjango with the kitchen sink, but this feels like a very useful feature - I've got several small static sites which I really wanted some of Django's features for, but setting up a full Django project felt overkill. A nanodjango script with a couple of models and some templates would have been perfect.
Probably should depend on #35
Usage:
nanodjango <new_command> script.py /path/to/site
. Possible command name:staticsite
- most descriptive, if a bit long (I know I'll typestatic-site
at some point)static
- shorter, but could confuse people with django's static files (ienanodjango static ..
vsnanodjango manage .. collectstatic
)build
- not specific to building a static file - could conflict with some sort of asset build command, should that ever be neededpublish
- implies deployment, remote serverPossible libraries to base it on, in order of github star popularity:
BuildableMixin
, seems people would need to explicitly use CBVs, which I'm not wild aboutIt looks like some of these packages will also deploy to s3 etc. That'd be a pretty handy feature, but I'm not keen on adding two commands for this. If supported, it would be better as eg
nanodjango staticsite s3://...
It may also be good to have a
--watch
option - but only if there's a significant difference tonanodjango run
One other common use case would be to be running
nanodjango serve
on a private url, and have changes automatically trigger a build to a public one. That would be a nice feature, but I suspect out of scope - probably best handled with a HOWTO in the docs (touch a file, watch a file?)Unless anyone has further suggestions, this will be
pip install nanodjango[staticsite]
,nanodjango staticsite <script> <path>
, and be based ondjango-distill
, ordjango-freeze
if we run into problems with distill