Book Image

Django 1.0 Template Development

Book Image

Django 1.0 Template Development

Overview of this book

Table of Contents (17 chapters)
Django 1.0 Template Development
Credits
About the Author
About the Reviewers
Preface
Index

Setting up your cache system


Now that you've seen the various cache backends that Django offers, we can now start implementing the code to work with them. Regardless of the backend you chose, the code will be identical.

Configuring the cache backend

To tell Django which backend we intend to use, we will set a variable called CACHE_BACKEND in our mycompany/settings.py file. Each backend uses a slightly different value, so we'll run through each separately.

Database caching

In order to use the database caching backend, you also have to run the createcachetable command from the manage.py file. This example uses my_cache_table as the name of the table, but you're free to use whatever you like:

$ python manage.py createcachetable my_cache_table

Once you have your cache table set up, add the backend to your mycompany/settings.py file:

CACHE_BACKEND = 'db://my_cache_table'

Filesystem caching

Filesystem caching requires very little setup, and the backend points to an absolute directory path on your filesystem...