Closed mozz100 closed 3 years ago
This is because when you build a static site in the typical use case for django-distill
you would have the admin area to make the admin function locally to add content but the admin static files would serve no purpose on the actual site you want to deploy.
You would run collectstatic
which would copy over all the required static files for the site as well as a bunch of unused admin files to your static
directory. The distill-local
and distill-publish
commands had the admin and grapelli (a popular extension for the Django admin which uses its own directory) directories ignored so you don't upload a bunch of relatively pointless (in most cases) static files to your live site.
Is there a use case where you actually want to keep the static admin files and publish the admin images, CSS and so on to your static site? I'm happy to patch it to be a config option if there is a reasonable use case to keep them post static site generation, otherwise, you're welcome to submit a doc update to announce this behavior more publicly.
Cheers!
My use case is: I have a django site at ‘app.dev-esc.com’. (heroku, so I’m trying to avoid running python to serve static files).
It has its own static files needs, plus I have a static website (the “landing page” stuff) at ‘www.dev-esc.com’
I’ve really benefitted from django-distill because my website just drops out when I run the command. Push the .html files to s3, done. And so do all the static files, so I can just set ‘STATIC_URL’ to something beginning ‘https://www.dev-esc.com’ and everything works.
Everything except my admin site, that is!
It’s not too hard to add an extra ‘cp -r’ into my script. I just lost time working out what was special about ‘admin’.
I think, since I’ve already got my workaround, just mentioning ‘admin’ and ‘grappelli’ in the docs will help others.
I'll add a config tweak that defaults to the current behaviour but allows you to disable ignoring the admin dir. It's a reasonable request and not a big patch. Glad you find django-distill
useful!
Just curious, do you use the distill-publish
feature? Or push your files to S3 some other way?
setting settings.DISTILL_SKIP_ADMIN_DIRS = False
once a new release is up should do what you want. README updated to match.
This patch is in the latest 2.5
release available on Pypi now. pip install -U django-distill
to get it.
Thanks for your suggestion and input to the project.
I am really liking django-distill for a hobby project of mine. Spent quite a while wondering why, after I had run
collectstatic
and then rundistill-local
, the static files for every application exceptadmin
were ending up in my target directory.I now see that
admin
andgrappelli
are hard-coded in as exclusions - https://github.com/meeb/django-distill/blob/master/django_distill/renderer.py#L229How come these are excluded? The comments in the file don't help me understand. If there is no reason, I'll happily try and submit a pull request that stops it happening. If there is a good reason, I'll submit a pull request that mentions it in the documentation!