1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

magic-removal: Proofread docs/flatpages.txt

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2764 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-04-28 04:54:51 +00:00
parent 9327788e25
commit 3db13442a1

View File

@ -3,7 +3,8 @@ The flatpages app
================= =================
Django comes with an optional "flatpages" application. It lets you store simple Django comes with an optional "flatpages" application. It lets you store simple
"flat" HTML content in a database and handles the management for you. "flat" HTML content in a database and handles the management for you via
Django's admin interface and a Python API.
A flatpage is a simple object with a URL, title and content. Use it for A flatpage is a simple object with a URL, title and content. Use it for
one-off, special-case pages, such as "About" or "Privacy Policy" pages, that one-off, special-case pages, such as "About" or "Privacy Policy" pages, that
@ -23,10 +24,10 @@ Installation
To install the flatpages app, follow these steps: To install the flatpages app, follow these steps:
1. Add ``"django.contrib.flatpages"`` to your INSTALLED_APPS_ setting. 1. Add ``'django.contrib.flatpages'`` to your INSTALLED_APPS_ setting.
2. Add ``"django.contrib.flatpages.middleware.FlatpageFallbackMiddleware"`` 2. Add ``'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'``
to your MIDDLEWARE_CLASSES_ setting. to your MIDDLEWARE_CLASSES_ setting.
3. Run the command ``django-admin.py install flatpages``. 3. Run the command ``manage.py syncdb``.
.. _INSTALLED_APPS: http://www.djangoproject.com/documentation/settings/#installed-apps .. _INSTALLED_APPS: http://www.djangoproject.com/documentation/settings/#installed-apps
.. _MIDDLEWARE_CLASSES: http://www.djangoproject.com/documentation/settings/#middleware-classes .. _MIDDLEWARE_CLASSES: http://www.djangoproject.com/documentation/settings/#middleware-classes
@ -34,10 +35,10 @@ To install the flatpages app, follow these steps:
How it works How it works
============ ============
``django-admin.py install flatpages`` creates two tables in your database: ``manage.py syncdb`` creates two tables in your database: ``django_flatpage``
``django_flatpage`` and ``django_flatpage_sites``. ``django_flatpage`` is a and ``django_flatpage_sites``. ``django_flatpage`` is a simple lookup table
simple lookup table that essentially maps a URL to a title and bunch of text that simply maps a URL to a title and bunch of text content.
content. ``django_flatpage_sites`` associates a flatpage with a site. ``django_flatpage_sites`` associates a flatpage with a site.
The ``FlatpageFallbackMiddleware`` does all of the work. Each time any Django The ``FlatpageFallbackMiddleware`` does all of the work. Each time any Django
application raises a 404 error, this middleware checks the flatpages database application raises a 404 error, this middleware checks the flatpages database
@ -80,8 +81,8 @@ Via the Python API
------------------ ------------------
Flatpages are represented by a standard `Django model`_, which lives in Flatpages are represented by a standard `Django model`_, which lives in
`django/contrib/flatpages/models/flatpages.py`_. You can access flatpage `django/contrib/flatpages/models.py`_. You can access flatpage objects via the
objects via the `Django database API`_. `Django database API`_.
.. _Django model: http://www.djangoproject.com/documentation/model_api/ .. _Django model: http://www.djangoproject.com/documentation/model_api/
.. _django/contrib/flatpages/models/flatpages.py: http://code.djangoproject.com/browser/django/trunk/django/contrib/flatpages/models/flatpages.py .. _django/contrib/flatpages/models/flatpages.py: http://code.djangoproject.com/browser/django/trunk/django/contrib/flatpages/models/flatpages.py
@ -90,17 +91,17 @@ objects via the `Django database API`_.
Flatpage templates Flatpage templates
================== ==================
By default, flatpages are rendered via the template ``flatpages/default``, but By default, flatpages are rendered via the template ``flatpages/default.html``,
you can override that for a particular flatpage. but you can override that for a particular flatpage.
Creating the ``flatpages/default`` template is your responsibility; in your Creating the ``flatpages/default.html`` template is your responsibility; in
template directory, just create a ``flatpages`` directory containing a file your template directory, just create a ``flatpages`` directory containing a
``default.html``. file ``default.html``.
Flatpage templates are passed a single context variable, ``flatpage``, which is Flatpage templates are passed a single context variable, ``flatpage``, which is
the flatpage object. the flatpage object.
Here's a sample ``flatpages/default`` template:: Here's a sample ``flatpages/default.html`` template::
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd"> "http://www.w3.org/TR/REC-html40/loose.dtd">