django-bakery — django-bakery 0.7.6 documentation

# 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 so you can host them using a static file service like Amazon S3.

At the Los Angeles Times Data Desk, 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:

1. No database crashes
2. Zero server configuration and upkeep
3. No need to optimize your app code
4. You don’t pay to host CPUs, only bandwidth
5. An offline administration panel is more secure
6. 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

- Getting started
  - Installation
  - Configuration
  - Execution
  - Optimization
- Common challenges
  - Configuring where detail pages are built
  - Building JSON instead of HTML
  - Building a single view on demand
- Buildable views
  - BuildableTemplateView
  - BuildableListView
  - BuildableDetailView
  - Buildable404View
  - BuildableRedirectView
- Buildable models
  - Models that build themselves
    - BuildableModel
  - Models that publish themselves
    - AutoPublishingBuildableModel
- Buildable feeds
  - BuildableFeed
- Settings variables
  - ALLOW_BAKERY_AUTO_PUBLISHING
  - BUILD_DIR
  - BAKERY_VIEWS
  - AWS_BUCKET_NAME
  - AWS_ACCESS_KEY_ID
  - AWS_SECRET_ACCESS_KEY
  - BAKERY_GZIP
  - GZIP_CONTENT_TYPES
  - DEFAULT_ACL
  - BAKERY_CACHE_CONTROL
- Management commands
  - build
  - buildserver
  - publish
  - unbuild
  - unpublish
- Changelog
  - 0.7.7
  - 0.7.6
  - 0.7.5
  - 0.7.4
  - 0.7.3
  - 0.7.1
  - 0.6.4
  - 0.6.3
  - 0.6.0
  - 0.5.0
  - 0.4.2
  - 0.4.1
  - 0.4.0
  - 0.3.0
  - 0.2.0
  - 0.1.0
- Credits

## 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.

## Contributing

- Code repository: https://github.com/datadesk/django-bakery
- Issues: https://github.com/datadesk/django-bakery/issues
- Packaging: https://pypi.python.org/pypi/django-bakery
- Testing: https://travis-ci.org/datadesk/django-bakery
- Coverage: https://coveralls.io/r/datadesk/django-bakery