Skip to content
100644 59 lines (45 sloc) 1.87 KB
180c4f3 SVN was being a dick.
Clinton Ecker authored
1 Think of it as flatpages for small bits of reusable content you might want to
2 insert into your templates and manage from the admin interface.
4 This is really nothing more than a model and a template tag.
6 By adding `chunks` to your installed apps list in your Django project and
7 performing a `./ syncdb`, you'll be able to add as many "keyed" bits
8 of content chunks to your site.
10 The idea here is that you can create a chunk of content, name it with a unique
11 key (for example: `home_page_left_bottom`) and then you can call this content
12 from a normal template.
14 Why would anyone want this?
16 It essentially allows someone to define "chunks" (I had wanted to call it
17 blocks, but that would be very confusing for obvious reasons) of content in
18 your template that can be directly edited from the awesome Django admin
19 interface. Throwing a rich text editor control on top of it make it even
20 easier.
22 Template tag usage:
24 {% load chunks %}
25 <html>
26 <head>
27 <title>Test</title>
28 </head>
29 <body>
30 <h1> Blah blah blah</h1>
31 <div id="sidebar">
32 ...
33 </div>
34 <div id="left">
35 {% chunk "home_page_left" %}
36 </div>
37 <div id="right">
38 {% chunk "home_page_right" %}
39 </div>
40 </body>
41 </html>
43 This is really helpful in those cases where you want to use
44 `django.contrib.flatpages` but you need multiple content areas. I hope this
45 is helpful to people and I'll be making minor edits as I see them necessary.
47 Caching
49 If you want to cache the content of your chunks you can pass along a caching
50 time argument in your chunk tag. Example:
52 {% chunk "home_page_left" 3600 %}
54 The caching time is specified in seconds. For caching to work properly you
55 must configure a cache backend in your See the Django
56 documentation for more information:
Something went wrong with that request. Please try again.