Coder Social home page Coder Social logo

amycthomas / django-distill-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from meeb/django-distill-example

0.0 0.0 0.0 58 KB

An example fully working statically generated website using Django Distill

License: MIT License

Makefile 1.93% Python 73.48% CSS 0.38% HTML 24.21%

django-distill-example's Introduction

django-distill-example

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.

Usage

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:

  • Username: blogadmin
  • Password: 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.

Detailed steps to get a site live

  1. Go and create an account on Netlify
  2. Create working Django website with some URLs wrapped by Distill, or clone / fork this repo
  3. Check that ./manage.py distill-local some-directory creates a working static copy of your site
  4. Create a build script for simplicity, see the Makefile 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.
  5. Make sure you set the correct Netlify runtime, see the runtime.txt file in this repo for an example. Remember, no trailing line breaks!
  6. Link your Netlify account to your GitHub or GitLab or other repo account
  7. Create the domain on Netlify using your repo as the source, it will ask you for some configuration details. In the "Build command" option put make (or whatever your shell script is if you created one instead of a makefile) and in the "Publish directory" option put public.
  8. Click "Deploy site"

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.

django-distill-example's People

Contributors

meeb avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.