Skip to content

Commit

Permalink
Added a caching setting to vary the amount of time the view is cached
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Oordt committed Apr 5, 2010
1 parent 4700b26 commit b0468cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion categories/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from django.conf import settings

ALLOW_SLUG_CHANGE = getattr(settings, 'CATEGORIES_ALLOW_SLUG_CHANGE', False)
ALLOW_SLUG_CHANGE = getattr(settings, 'CATEGORIES_ALLOW_SLUG_CHANGE', False)

CACHE_VIEW_LENGTH = getattr(settings, 'CATEGORIES_CACHE_VIEW_LENGTH', 3600)
3 changes: 2 additions & 1 deletion categories/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from django.views.decorators.cache import cache_page
from django.template.loader import select_template
from categories.models import Category
from settings import CACHE_VIEW_LENGTH

@cache_page(3600)
@cache_page(CACHE_VIEW_LENGTH)
def category_detail(request, path, with_stories=False,
template_name='categories/category_detail.html'):
path_items = path.strip('/').split('/')
Expand Down

0 comments on commit b0468cc

Please sign in to comment.