Django flatpages

Never had to use flatpages before in Django but when I did, found a minor ‘?bug?’ at v1.1.1 that, is nothing special but, could ‘mindbrick’ some of us.

Here’s the quickest/normal way 😀

  1. Add ‘django.contrib.flatpages’ to your INSTALLED_APPS, at settings.py
  2. Add ‘django.contrib.flatpages.middlewareFlatpageFallbackMiddleware’ to MIDDLEWARE_CLASSES at same file.
  3. ** Check at settings.py if the SITE_ID matches the current site*
  4. Here’s the ‘bug’, make sure the ID fits the actual site. If you can’t check the id at the admin panel, just ‘sqlite3 your.db‘ then ‘select * from django_site;‘ to check the correct ID.
  5. In the site path, just run: ‘python manage.py syncdb’ to update the DB with new features.
  6. Just add flatpages in the Admin panel, linking it to your current site.
  7. Remember to build a template on templates/flatpages/default.html like this one:

** – Here’s the ‘bug’, make sure the ID fits the actual site. If you can’t check the id at the admin panel, just ‘sqlite3 your.db‘ then ‘select * from django_site;‘ to check the correct ID.

10
Nov 2009
POSTED BY
POSTED IN Django
DISCUSSION 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *