This is a complete working example of how to build a static site with Django, Django Distill and Django CacheKiller. It was built and tested under Python 3.6, but any modern 3.x Python should work.
This site is fully working and a live demo if this sites output is available here, hosted on Netlify:
https://django-distill-example.meeb.org/
This example is slightly unusual in that it commits the SQLite database with the content into the repository, this is fine for single developer or small teams, however larger sites with a lot of content should use a secured external database or you'll end up overwriting each others content edits with endless merge conflicts.
You can use this style of site generation on any platform which supports continuous deployment, good (and free or low cost) examples being:
This example repo includes working demo content and a working Django admin. To get it working, just clone this repository and install the requirements (using a virtual env would be a good idea):
$ pip install -r requirements.txt
Then run the development server:
$ ./manage.py runserver
You should be able to access the site on your local development server at http://127.0.0.1:8000/. The admin is at http://127.0.0.1:8000/admin/ and the default credentials are:
blogadmin
blogadmin
Note This is obviously not at all secure, the static site once generated is
secure, however the Django interface is only suitable for local development
and content editing on a secure computer. If you want to secure the development
server interface make sure you change the SECRET_KEY
to something sensible
(and store it in an environment variable).
To build a static website into a public
directory make sure you have make
installed, for example on Debian or Ubuntu systems:
# May need "sudo" prefix
$ apt install make
Then in the project directory just run:
$ make
And you static site will be in the public
directory.
./manage.py distill-local some-directory
creates a working
static copy of your siteMakefile
in this repo for an
example, make this build script create the site in a directory called
public
- you can use a shell script or whatever you like.runtime.txt
file in
this repo for an example. Remember, no trailing line breaks!make
(or whatever your shell script is if you created one instead of a makefile)
and in the "Publish directory" option put public
.After a minute or two your static site should be live! Now every time you commit some changes, including content into the SQLite database, and do a push your changes will be automatically deployed live and your static assets will have their cache-busting tags updated.