Django CMS

5.0.6 · active · verified Fri Apr 17

django-cms is a lean enterprise content management system built on Django. It provides an intuitive drag-and-drop interface for managing pages and content, extensive plugin architecture, and multilingual support. The current stable version is 5.0.6, with regular patch releases and significant new major versions (like 4.x and 5.x) introducing substantial changes and requiring careful upgrade paths.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart outlines the minimal configuration for integrating Django CMS into an existing Django project. It includes essential `INSTALLED_APPS`, `MIDDLEWARE`, `TEMPLATES` context processors, a basic `urls.py` setup, and a simple `base.html` template. After configuring, run `python manage.py makemigrations` (if needed), `python manage.py migrate`, `python manage.py createsuperuser`, and `python manage.py collectstatic`. Then start the server and navigate to `/admin` to create your first page.

# settings.py
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

INSTALLED_APPS = [
    'djangocms_admin_style', # Must be before django.contrib.admin
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites', # Required by CMS
    'cms', # Must be before 'menus'
    'menus', # Must be before 'sekizai'
    'sekizai', # Required for JS/CSS resource management
    'treebeard', # Required by CMS for page trees
    'djangocms_text_ckeditor', # Example plugin
    # Add your project apps here
]

SITE_ID = 1

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'cms.middleware.utils.ApphookReloadMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.page.PageMiddleware',
]

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'sekizai.context_processors.sekizai',
                'cms.context_processors.cms_settings',
            ],
        },
    },
]

DEBUG = True
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'insecure-dev-key-please-change-this')
ALLOWED_HOSTS = ['*']
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

# urls.py
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('cms.urls')), # This must be the last URL pattern
]

# templates/base.html
# (create this file in your project's 'templates' directory)
{% load cms_tags sekizai_tags menu_tags %}
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>{% page_attribute "page_title" default_value="My Site" %}</title>
    {% render_block "css" %}
</head>
<body>
    {% cms_toolbar %}
    <header>
        <h1><a href="/">My Django CMS Site</a></h1>
        {% show_menu 0 100 100 100 %}
    </header>
    <main>
        {% placeholder "content" %}
    </main>
    <footer>
        {% render_block "js" %}
    </footer>
</body>
</html>

view raw JSON →