Makes FlatPage fixtures easily



This is a Django app that makes fixtures for FlatPages more convenient.

One of the main drawbacks with django.contrib.flatpages is that the only way to store your flat pages with your source files is as a fixture. django-fileflatpages solves this problem by inserting files as FlatPages from your apps.

What django-fileflatpages gives you is the Django management command loadflatpages. For each app in your projects INSTALLED_APPS, loadflatpages will look for the directory flatpages. If it finds a flatpages directory, it adds each file in the flatpages directory as a flatpage.

The FlatPage attributes are specified using comments at the top of each file. django-fileflatpages starts at the first line, and for each line it looks for attribute = value comments. As soon as django-fileflatpages encounters a non-comment line, it stops looking for further comments.

For example:

.. -*- mode: rst -*-
.. url = /about/
.. title = About
.. template_name = flatpages/rst.html
.. enable_comments = False

Hello World


FlatPage(url='/about', title='About', template_name='flatpages/rst.html',
         enable_comments=False, sites=[settings.SITE_ID],

There is one special field you can specify, remove_comments = True. This will remove comment lines with field = value directives from the content that is stored in the database.

The main website for django-fileflatpages is but there is also a git mirror at


  • Install django-fileflatpages with your favourite python package manager:

    pip install django-fileflatpages
  • Add "fileflatpages" to your INSTALLED_APPS setting:

        # ...
  • Make sure you have also enabled flatpages for your project.

Now when you run loadflatpages all installed apps will have there flatpages added.

Example Site

An example project is stored under example_project directory. See the directory example_project/app/flatpages for the flatpages that get added to the database. To get the example site up and running under a virtual environment follow these steps:

$ virtualenv --no-site-packages env
$ . env/bin/activate
$ pip install -r example_project/requirements.txt
$ python install
$ python example_project/ syncdb
$ python example_project/ loadflatpages # What django-fileflatpages adds
$ python example_project/ runserver

You should now be able to browse the example site at http://localhost:8000/