Ticket #14556: 14556-1.diff

File 14556-1.diff, 2.0 KB (added by claudep, 4 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.
    4444
     45Then either:
     46
     473. Add an entry in your URLconf. For example::
     48
     49    urlpatterns = patterns('',
     50        ('^pages/', include('django.contrib.flatpages.urls')),
     51    )
     52
     53or:
     54
    45553. Add ``'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'``
    4656   to your :setting:`MIDDLEWARE_CLASSES` setting.
    4757
    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.
    5969
     70Using the URLconf
     71-----------------
     72
     73There are several ways to include the flat pages in your URLconf. You can
     74dedicate a particular namespace to flat pages, like::
     75
     76    urlpatterns = patterns('',
     77        ('^pages/', include('django.contrib.flatpages.urls')),
     78    )
     79
     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::
     82
     83    <... your patterns ...>
     84    urlpatterns = patterns('django.contrib.flatpages.views',
     85        (r'^(?P<url>.*)$', 'flatpage'),
     86    )
     87
     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
     90tag::
     91
     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    )
     96
     97Using the middleware
     98--------------------
     99
    60100The :class:`~django.contrib.flatpages.middleware.FlatpageFallbackMiddleware`
    61 does all of the work.
     101can do all of the work.
    62102
    63103.. class:: FlatpageFallbackMiddleware
    64104
Back to Top