Skip to main content

like flatpages, but with templates.

Project description

like flatpages, but with templates

This is like Django’s contrib.flatpages, but without the database. It’s just static html documents served from your filesystem.

Motivation

I’ve been using the flatpages app for a long time, but somewhere along the line I started keeping my flatpage content (snippets of html) in the git repo with the rest of my project. Any time I made a change to a flatpage, I’d edit the file locally, commit the changes, then copy and paste the new content into the relevant flatpage.

Why not just serve these from my templates directory?

That’s what staticflatpages does.

Installation

Install this app with pip:

pip install django-staticflatpages

Or install it directly from this repo:

pip install -e git+git://github.com/bradmontgomery/django-staticflatpages.git#egg=django-staticflatpages

Configuration

  1. Add staticflatpages to your INSTALLED_APPS.

  2. Add staticflatpages.middleware.StaticFlatpageFallbackMiddleware to your MIDDLEWARE_CLASSES

  3. Create a staticflatpages template directory. This should be a subdirectory of one of the templates in your TEMPLATE_DIRS. Any templates you include here (except for a base.html) will get served as a static page.

For example, assuming your project-level template directory is named “templates”, the url /about/ will point to templates/staticflatpages/about.html. Likewise, the url /about/team/ will point to templates/staticflatpages/about/team.html.

Sitemaps

This app also supports sitemaps. To enable these just set up a sitemap (e.g. in your Root URLconf):

from staticflatpages.sitemaps import StaticFlatpageSitemap

sitemaps = {
    'staticflatpages': StaticFlatpageSitemap,
}

Then include your sitemaps urls as normal:

urlpatterns += patterns('django.contrib.sitemaps.views',
    url(r'^sitemap\.xml$', 'index', {'sitemaps': sitemaps}),
    url(r'^sitemap-(?P<section>.+)\.xml$', 'sitemap', {'sitemaps': sitemaps}),
)

You may also want to include the following settings:

  • STATICFLATPAGES_CHANGEFREQ: Corresponds to the Sitemap.changefreq attribute (defaults to never).

  • STATICFLATPAGES_PRIORITY: Corresponds to the Sitemap.priority attribute (defaults to 0.5).

License

This code is distributed under the terms of the MIT license. See the LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-staticflatpages-0.2.0.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file django-staticflatpages-0.2.0.tar.gz.

File metadata

File hashes

Hashes for django-staticflatpages-0.2.0.tar.gz
Algorithm Hash digest
SHA256 69ca32636cc6298ee61f4a8dc910db87e239ea65dfb95864c66e66ea3e2de350
MD5 1e140ded780687112279cf428750b98e
BLAKE2b-256 5a936b84c30408e1ff1390787722ebc8cddad350db7cf80ddac0fba3583d4b3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page