Configuration

Out of the box django-cms comes not with a lot features. But with some settings you can extend it to a enterprise ready solution. All settings described here can be found in cms/settings.py or in the plugins folder if they have a settings.py

All thoose settings should be placed in your project settings.py

CMS_TEMPLATES

A list of the templates you can select for a page.

Example:

CMS_TEMPLATES = (
        ('base.html', gettext('default')),
        ('2col.html', gettext('2 Column')),
        ('3col.html', gettext('3 Column')),
        ('extra.html', gettext('Some extra fancy template')),
)

CMS_TEMPLATE_INHERITANCE

This is optional

Example:

CMS_TEMPLATE_INHERITANCE = True

If this is enabled, pages have the additional template option to inherit their template from the nearest ancestor. Adding new pages defaults to this if the new page is not a root page.

CMS_PLACEHOLDER_CONF

Is used to configure the placeholders. This is optional

Example:

CMS_PLACEHOLDER_CONF = {
        'content': {
                'plugins': ('TextPlugin', 'PicturePlugin'),
                'extra_context': {"theme":"wide"},
                'name':gettext("Content")
},
'right-column': {
        "plugins": ('TeaserPlugin', 'LinkPlugin'),
        "extra_context": {"theme":"small"},
                'name':gettext("Right Column")
},
}

plugins

A list of plugins that can be added to this placeholder. If not supplied all plugins can be selected.

extra_context

Extra context that plugins in this placeholder receive.

name

The name displayed in admin. With the gettext stub it can be internationalized.

CMS_PERMISSION

Example:

CMS_PERMISSION = True

If this is enabled you get 3 new models in Admin:

  • Pages global permissions
  • User groups - page
  • Users - page

In the edit-view of the pages you can now assign users to pages and grant them permissions. In the global permissions you can set the permissions for users globaly.

If a user has the right to create new users he can now do so in the “Users - page”. But he will only see the users he created. The users he created also can only have the rights he already has. So if he has only the right to edit a certain page all users he created also only can edit this page. Naturally he can even more limit the rights of the users he creates.

CMS_MODERATOR

Example:

CMS_MODERATOR = True

If set to true gives you a new column “moderation” in the tree view. You can select to moderate pages or hole trees. If a page is under moderation you will recieve an email if somebody changes a page and you will be asked to approve the changes. Only after you approved the changes they will be updated on the live site. If you change a page you moderate yourself you will need to approve it anyway. This allows you change a lot of pages for a new version of the site and can go live with all the changes on the same time.

CMS_SHOW_START_DATE & CMS_SHOW_END_DATE

Example:

CMS_SHOW_END_DATE = True
CMS_SHOW_START_DATE = True

This adds 2 new date-time fields in the advanced-settings tab of the page. With this option you can limit the time a page is published.

CMS_URL_OVERWRITE

Example:

CMS_URL_OVERWRITE = True

This adds a new field “url overwrite” in your in the advanced-settings tab of the page. With this field you can overwrite the whole relative url of the page.

CMS_MENU_TITLE_OVERWRITE

Example:

CMS_MENU_TITLE_OVERWRITE = True

This adds a new field “menu title” besides the title field. With this field you can overwrite the title that is displayed in the menu.

To access the menu title in the template use:

{{ page.get_menu_title }}

CMS_REDIRECTS

Example:

CMS_REDIRECTS = True

This adds a new field “redirect” to the advanced-settings tab of the page You can enter a url and if someone visits this page he gets redirected to this url.

Note: Don’t use this too much. There is django.contrib.redirect for this purpose

CMS_SEO_FIELDS

Example:

CMS_SEO_FIELDS = True

This adds a new Fieldset “SEO Fields” in the page admin. You can set there the Page Title, Meta Keywords and the Meta Description

To access the fields in the template use:

{% load cms_tags %}
<head>
        <title>{% page_attribute page_title %}</title>
        <meta name="description" content="{% page_attribute meta_description %}"/>
        <meta name="keywords" content="{% page_attribute meta_keywords %}"/>
        ...
        ...
</head>

CMS_FLAT_URLS

Example:

CMS_FLAT_URLS = True

If this is enabled the slugs are not nested in the urls.

So a page with slug “world” will have an url “/world” even it is a child of the page “hello” If disabled the page would have an url: “/hello/world/”

CMS_NAVIGATION_EXTENDERS

Example:

CMS_NAVIGATION_EXTENDERS = (
        ('shop.navigation.get_nodes', 'Shop Categories'),
        ('gallery.navigation.get_nodes', 'Galleries'),
)

Navigation extenders allow you to extend the menu. In Brief: A tuble with a python path to a function that returns a list of navigation nodes For detailed explanation read the navigation docs section :ref:`extending_the_menu`.

System Message: ERROR/3 (<string>, line 196); backlink

Unknown interpreted text role “ref”.

This gives you a new field in the advanced-settings tab of the page. You can there say that one navigation extender is attached to this page.

CMS_NAVIGATION_MODIFIERS

Example:

CMS_NAVIGATION_MODIFIERS = (
        ('blog.navigation.add_blog_categories'),
)

Navigation modifiers are functions in other apps that can modify the navigation. They can add, remove, reorder navigation nodes.

#TODO: more docs needed

CMS_APPLICATIONS_URLS

Example:

CMS_APPLICATIONS_URLS = (
('someapp.urls', 'Some application'),
('sampleapp.urls_en', 'Sample application English URLs'),
('sampleapp.urls_de', 'Sample application German URLs'),
)

You can let cms handle the urls of other 3th party apps and attach them to pages. For example you have a page named blog and a blog application. You can attach the blog urls.py to the blog page. After this every url after blog page will be handled by the blog application. The nice thing about this is the cms can be used in the templates of the blog application. So you can use placeholders in the templates and they will be filled up with plugins that are defined in the blog page. Also the blog menu item will be selected if you are on a page that is handled by the blog application.

At the moment if you change this settings you should restart the server as there is a cache invalidation bug.

An simpler way is to have a page with the same url as the app. This will give you also the plugin and menu abilities but has some limitations when it comes to i18n and urls.

CMS_UNIQUE_SLUGS

Example:

CMS_UNIQUE_SLUGS = True

Defines if the slugs should be unique over all sites and languages. This setting is changed automatically according to other settings. Do not set it in you settings.py if you don’t know what you are doing.

CMS_SOFTROOT

Example:

CMS_SOFTROOT = True

This adds a new field “softroot” to you advanced-settings tab in the page. If a page is marked as softroot the menu will only display the items till the softroot. If you have a huge site you can partition the menu with this.

CMS_HIDE_UNTRANSLATED

Example:

CMS_HIDE_UNTRANSLATED = False

By default django-cms hides the menu items that are not translated yet in the current language. With this setting set to False they will show up anyway.

CMS_LANGUAGE_FALLBACK

Example:

CMS_LANGUAGE_FALLBACK = True

This will redirect the browser to the same page in an other language if the page is not available in the current language.

CMS_LANGUAGES

Which language should be used by the cms?

Example:

CMS_LANGUAGES = (
    ('fr', gettext('French')),
    ('de', gettext('German')),
    ('en', gettext('English')),
)

Normally the cms takes the LANGUAGES from the settings.py. With this you can overwrite this. Be sure that you don’t have more language in here than in the LANGUAGES setting.

CMS_CONTENT_CACHE_DURATION

Example:

CMS_CONTENT_CACHE_DURATION = 60

Defines how long page content should be cached, including navigation and admin menu.

Default is 60

CMS_MEDIA_PATH

Example:

CMS_MEDIA_PATH = "cms/"

The path from MEDIA_ROOT to the media files located in cms/media/

default: cms/

CMS_MEDIA_ROOT

Example:

CMS_MEDIA_ROOT = "settings.MEDIA_ROOT + "/cms/"

The path to the media root of the cms media files.

Default: settings.MEDIA_ROOT + CMS_MEDIA_PATH

CMS_MEDIA_URL

Example:

CMS_MEDIA_URL = "/media/cms/"

The location of the media files that are located in cms/media/cms/

default: MEDIA_URL + CMS_MEDIA_PATH

CMS_PAGE_MEDIA_PATH

By default the cms creates a folder in called ‘cms_page_media’ in your static files folder where all uploaded media files are stored. The media files are stored in subfolders numbered with the id of the page.

Example:

CMS_PAGE_MEDIA_PATH = 'cms_page_media/'

Questions/Feedback

If you notice errors with this documentation, please open a ticket and let us know!

Please only use the ticket tracker for criticisms and improvements on the docs. For tech support, ask in the IRC channel or post to the django-cms mailing-list.