django-bakery¶
A set of helpers for baking your Django site out as flat files
Why and what for¶
The code documented here is intended to make it easier to save every page generated by a database-backed site as a flat file. This allows you to host the site using a static-file service like Amazon S3.
We call this process “baking.” It’s our path to cheap, stable hosting for simple sites. We’ve used it for publishing election results, timelines, documents, interactive tables, special projects and numerous other things.
The system comes with some major advantages, like:
No database crashes
Zero server configuration and upkeep
No need to optimize your app code
You don’t pay to host CPUs, only bandwidth
An offline administration panel is more secure
Less stress (This one can change your life)
There are drawbacks. For one, you have to integrate the “bakery” into your code base. More important, a flat site can only be so complex. No online database means your site is all read and no write, which means no user-generated content and no complex searches.
Django’s class-based views are at the heart of our approach. Putting all the pieces together is a little tricky at first, particularly if you haven’t studied the Django source code or lack experience working with Python classes in general. But once you figure it out, you can do all kinds of crazy things: Like configuring Django to bake out your entire site with a single command.
Here’s how.
Documentation¶
In the wild¶
Hundreds of Los Angeles Times custom pages at latimes.com/projects and graphics.latimes.com
The California Civic Data Coalition’s data downloads
The Dallas Morning News’ legislative tracker
Newsday’s police misconduct investigation
Southern California Public Radio’s water report tracker
The Daily Californian’s sexual misconduct case tracker
The pretalx open-source conference management system
The static-site extension to the Wagtail content management system
Have you used django bakery for something cool? Send a link to b@palewi.re and we will add it to this list.
Considering alternatives¶
If you are seeking to “bake” out a very simple site, maybe you don’t have a database or only a single page, it is quicker to try Tarbell or Frozen-Flask, which don’t require all the overhead of a full Django installation.
This library is better suited for projects that require a database, want to take advantage of other Django features (like the administration panel) or require more complex views.
Contributing¶
Code repository: https://github.com/palewire/django-bakery/
Packaging: https://pypi.python.org/pypi/django-bakery