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 gen­er­ated by a data­base-backed site as a flat file. This allows you to host the site us­ing a stat­ic-file ser­vice like Amazon S3.

We call this pro­cess “bak­ing.” It’s our path to cheap­, stable host­ing for simple sites. We’ve used it for pub­lish­ing elec­tion res­ults, timelines, doc­u­ments, in­ter­act­ive tables, spe­cial pro­jects and numerous other things.

The sys­tem comes with some ma­jor ad­vant­ages, like:

  1. No data­base crashes

  2. Zero serv­er con­fig­ur­a­tion and up­keep

  3. No need to op­tim­ize your app code

  4. You don’t pay to host CPUs, only band­width

  5. An off­line ad­min­is­tra­tion pan­el is more se­cure

  6. Less stress (This one can change your life)

There are draw­backs. For one, you have to integrate the “bakery” in­to your code base. More im­port­ant, a flat site can only be so com­plex. No on­line data­base means your site is all read and no write, which means no user-gen­er­ated con­tent and no com­plex 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.


In the wild

Have you used django bakery for something cool? Send a link to 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 to suited for projects that require a database, want to take advantage of other Django features (like the administration panel) or require more complex views.