~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to docs/ref/contrib/flatpages.txt

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
Here are some examples of flatpages on Django-powered sites:
28
28
 
29
 
    * http://www.chicagocrime.org/about/
30
 
    * http://www.everyblock.com/about/
31
29
    * http://www.lawrence.com/about/contact/
 
30
    * http://www2.ljworld.com/site/rules/
32
31
 
33
32
Installation
34
33
============
41
40
       
42
41
       Also make sure you've correctly set :setting:`SITE_ID` to the ID of the
43
42
       site the settings file represents. This will usually be ``1`` (i.e.
44
 
       ``SITE_ID = 1``, but if you're not using the sites framework to manage
 
43
       ``SITE_ID = 1``, but if you're using the sites framework to manage
45
44
       multiple sites, it could be the ID of a different site.
46
45
       
47
46
    2. Add ``'django.contrib.flatpages'`` to your :setting:`INSTALLED_APPS`
81
80
The middleware only gets activated for 404s -- not for 500s or responses of any
82
81
other status code.
83
82
 
 
83
.. admonition:: Flatpages will not apply view middleware
 
84
 
 
85
   Because the ``FlatpageFallbackMiddleware`` is applied only after
 
86
   URL resolution has failed and produced a 404, the response it
 
87
   returns will not apply any :ref:`view middleware <view-middleware>`
 
88
   methods. Only requests which are successfully routed to a view via
 
89
   normal URL resolution apply view middleware.
 
90
 
84
91
Note that the order of :setting:`MIDDLEWARE_CLASSES` matters. Generally, you can
85
92
put :class:`~django.contrib.flatpages.middleware.FlatpageFallbackMiddleware` at
86
93
the end of the list, because it's a last resort.
127
134
==================
128
135
 
129
136
By default, flatpages are rendered via the template
130
 
:file:`flatpages/default.html`, but you can override that for a particular
131
 
flatpage.
 
137
:file:`flatpages/default.html`, but you can override that for a
 
138
particular flatpage: in the admin, a collapsed fieldset titled
 
139
"Advanced options" (clicking will expand it) contains a field for
 
140
specifying a template name. If you're creating a flat page via the
 
141
Python API you can simply set the template name as the field
 
142
``template_name`` on the ``FlatPage`` object.
132
143
 
133
144
Creating the :file:`flatpages/default.html` template is your responsibility;
134
145
in your template directory, just create a :file:`flatpages` directory