Ticket #14556: 14556-1.diff

File 14556-1.diff, 2.0 KB (added by Claude Paroz, 7 years ago)

Draft of possible flatpages docs complement

  • docs/ref/contrib/flatpages.txt

    diff --git a/docs/ref/contrib/flatpages.txt b/docs/ref/contrib/flatpages.txt
    index 0b20ecc..6856f19 100644
    a b To install the flatpages app, follow these steps: 
    42422. Add ``'django.contrib.flatpages'`` to your :setting:`INSTALLED_APPS`
    4343   setting.
     45Then either:
     473. Add an entry in your URLconf. For example::
     49    urlpatterns = patterns('',
     50        ('^pages/', include('django.contrib.flatpages.urls')),
     51    )
    45553. Add ``'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'``
    4656   to your :setting:`MIDDLEWARE_CLASSES` setting.
    and ``django_flatpage_sites``. ``django_flatpage`` is a simple lookup table 
    5767that simply maps a URL to a title and bunch of text content.
    5868``django_flatpage_sites`` associates a flatpage with a site.
     70Using the URLconf
     73There are several ways to include the flat pages in your URLconf. You can
     74dedicate a particular namespace to flat pages, like::
     76    urlpatterns = patterns('',
     77        ('^pages/', include('django.contrib.flatpages.urls')),
     78    )
     80You can also set it up as a "catchall" pattern. In this case, it is important
     81to place the pattern '''at the end''' of the other urlpatterns::
     83    <... your patterns ...>
     84    urlpatterns = patterns('django.contrib.flatpages.views',
     85        (r'^(?P<url>.*)$', 'flatpage'),
     86    )
     88Another common setup is to use flat pages for a limited set of known pages and
     89to hard code the urls, so as to be able to reference them with the url template
     92    urlpatterns+= patterns('django.contrib.flatpages.views',
     93        url(r'^about-us/$', 'flatpage', {'url': '/about-us/'}, name='about'),
     94        url(r'^license/$', 'flatpage', {'url': '/license/'}, name='license'),
     95    )
     97Using the middleware
    60100The :class:`~django.contrib.flatpages.middleware.FlatpageFallbackMiddleware`
    61 does all of the work.
     101can do all of the work.
    63103.. class:: FlatpageFallbackMiddleware
Back to Top