Skip to main content

A micro-CMS for django. A bit like flatpages++.

Project description

django-micro-cms

A micro-CMS for django. A bit like flatpages++.

It is not a fully-fledged CMS with online editing and media management. All it does is allow you to manage pages and their templates and translations in the admin (and display the pages on your web site, naturally).

Installation

django-micro-cms has no external dependencies other than Django. It was tested against Django 1.6. To install django-micro-cms, simply

pip install django-micro-cms

There are two more things you have to do before you can use it on your page.

  1. Add microcms to your installed apps:

    INSTALLED_APPS = (
        [...],
        'microcms',
    )
  2. Add a URL config for your pages:

    urlpatterns = patterns('',
        url(r'^page(?P<url>/.*)$', 'microcms.views.pages', name='pages'),
        url(r'^admin/', include(admin.site.urls)),
    )

    You can add more than one URL config for your pages, but all pages will be available at each endpoint.

Usage

Using django-micro-cms is quite simple: create templates, create content, see it on the page. That’s all. All of the editing is done in the Django admin.

Templates

First you have to create one or more Template objects. These templates will be rendered when you display a page with it. They can {% extend %} pages from your Django web-page, which is a good idea if you have a base template, but they cannot themselves be extend-ed.

Inside the template, you can use several variables to insert your content:

title

The page title as a safe string.

content

The page content as a safe string.

CONTENT_LANGUAGE_CODE

The language code of the loaded content. This may be different from the language code of the page, because the language code of the page depends on the user preferences and the page URL (see below for details on language-loading). However, the language code of the content depends on the availability of content in that language. If no content in the requested language is available, the fallback language is used and that language code will be indicated here.

created

The date/time of the page creation.

last_modified

The date/time of the last modification of the page content.

Content

The second step is to create pages and content for them. Pages have a URL and a title. The URL is the part of the page URL that get’s parsed out as the view parameter in your URL definition. So if you have a page with /about/ as URL and in your URL definition this setup:

url(r'^page(?P<url>/.*)$', 'microcms.views.pages'),

then the full URL of that page will be:

/page/about/

The title attribute of the page will be available unescaped in the template as variable title.

For each page, you can add content. Only pages that have content parts defined are shown. If a page has no content in the fallback language, it will only be shown when the requested language version exists.

The content attribute of each language version is given to the template unescaped.

On the page

Each page is available under its URL (once there is at least one content part defined). Additionally, it is also available under its URL with a language code prepended.

An example.

Let’s say you have wired up the pages view as above, to be seen on the page as ^page(?P<url>/.*)$'. Then each page you create will be available at the URL you defined. For example, if you have pages with URLS /about/, /imprint/ and /about/contact/, the will be available as:

/page/about/
/page/imprint/
/page/about/contact/

If a user requests the page in a locale that has defined content, then the correct content will be served up. If you have content for locales en and de for example, and a user requests the page in German, the de variant of the content will be served. If you have variants in es and es-mx, and a user requests content in es-ar, the es variant will be served.

To allow serving specific languages, you can prepend the language code to the page part of your URL. The above-outlined variants will be available under the following URLs:

/page/en/about/
/page/de/about/
/page/es/about/
/page/es-mx/about/

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-micro-cms-1.1.0.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file django-micro-cms-1.1.0.tar.gz.

File metadata

File hashes

Hashes for django-micro-cms-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7819432aa8063e8b76739f566ec96fc102f588e81da6d111fde221496deb10a5
MD5 5482da3bb44c3e0059ec43fc1d7574c2
BLAKE2b-256 1fb7b682bda675dd936bd6da5a458b1d0ddd27a5107d9bd6339de6a49818425e

See more details on using hashes here.

Supported by

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