0
# Django CMS
1
2
A comprehensive Django-based enterprise content management system that provides flexible, extensible functionality for building content-driven websites. Django CMS features hierarchical page structure, plugin-based content management, multi-language support, advanced permission systems, and sophisticated admin interface with inline editing capabilities.
3
4
## Package Information
5
6
- **Package Name**: django-cms
7
- **Language**: Python
8
- **Installation**: `pip install django-cms`
9
10
## Core Imports
11
12
```python
13
import cms
14
from cms.api import create_page, add_plugin
15
from cms.models import Page, PageContent, Placeholder, CMSPlugin
16
```
17
18
For template usage:
19
```python
20
# In Django templates
21
{% load cms_tags %}
22
{% load menu_tags %}
23
```
24
25
## Basic Usage
26
27
```python
28
from cms.api import create_page, add_plugin
29
30
# Create a new CMS page
31
page = create_page(
32
title="Welcome",
33
template="template_1.html",
34
language="en",
35
slug="welcome"
36
)
37
38
# Add a text plugin to a placeholder
39
plugin = add_plugin(
40
placeholder=page.get_placeholders("en").get(slot="content"),
41
plugin_type="TextPlugin",
42
language="en",
43
body="<h1>Welcome to our site!</h1><p>This is sample content.</p>"
44
)
45
46
# Note: Publishing functionality has been removed from Django CMS core in v4+.
47
# For publishing, use packages like djangocms-versioning.
48
```
49
50
In Django templates:
51
```html
52
{% load cms_tags %}
53
54
<!-- Render a placeholder with inheritance -->
55
{% placeholder "content" %}
56
57
<!-- Render page attributes -->
58
<title>{% page_attribute "title" %}</title>
59
60
<!-- Create editable content areas -->
61
{% placeholder "sidebar" inherit %}
62
```
63
64
## Architecture
65
66
Django CMS is built around several core concepts that work together to provide flexible content management:
67
68
- **Pages**: Hierarchical page structure with tree-based organization and URL routing
69
- **Placeholders**: Named content areas within templates that can contain plugins
70
- **Plugins**: Modular content components (text, images, forms, etc.) that can be inserted into placeholders
71
- **Templates**: Django templates that define page layout and placeholder positions
72
- **Permissions**: Granular user and group permissions for pages, placeholders, and plugins
73
- **Multi-language**: Complete internationalization support with language fallbacks
74
- **Versioning**: Draft workflow with content versioning capabilities (publishing requires additional packages like djangocms-versioning)
75
76
The plugin architecture enables unlimited extensibility, allowing developers to create custom content types while maintaining consistent editing interfaces and permission systems.
77
78
## Capabilities
79
80
### Page and Content Management
81
82
Core functionality for creating, organizing, and managing CMS pages with hierarchical structure, URL routing, template assignment, and multi-language content support.
83
84
```python { .api }
85
def create_page(title, template, language, **kwargs): ...
86
def create_page_content(language, title, page, **kwargs): ...
87
def get_page_draft(page): ...
88
```
89
90
[Page Management](./pages.md)
91
92
### Plugin System
93
94
Extensible plugin architecture for adding modular content components to placeholders, with support for custom plugin development, nested plugins, and plugin-specific permissions.
95
96
```python { .api }
97
def add_plugin(placeholder, plugin_type, language, position="last-child", target=None, **data): ...
98
class CMSPluginBase: ...
99
```
100
101
[Plugin System](./plugins.md)
102
103
### Template Integration
104
105
Template tags and functionality for rendering CMS content in Django templates, including placeholder rendering, page attributes, navigation menus, and inline editing support.
106
107
```python { .api }
108
# Template tags (usage in templates)
109
{% placeholder "slot_name" %}
110
{% page_attribute "title" %}
111
{% render_model instance "field" %}
112
```
113
114
[Template Integration](./templates.md)
115
116
### User Management and Permissions
117
118
Comprehensive permission system with page-level, placeholder-level, and plugin-level permissions, user management utilities, and integration with Django's auth system.
119
120
```python { .api }
121
def create_page_user(username, email, password, **fields): ...
122
def assign_user_to_page(page, user, grant_all=False, **permissions): ...
123
def can_change_page(request): ...
124
```
125
126
[Permissions](./permissions.md)
127
128
### Menu System
129
130
Navigation menu framework with automatic page-based menu generation, custom menu providers, menu modifiers, and template tags for rendering navigation.
131
132
```python { .api }
133
class Menu: ...
134
class Modifier: ...
135
class NavigationNode: ...
136
```
137
138
[Menu System](./menus.md)
139
140
### Utilities and Helpers
141
142
Comprehensive utility functions for internationalization, URL handling, configuration management, and CMS-specific operations.
143
144
```python { .api }
145
def get_current_language(): ...
146
def get_page_from_request(request): ...
147
def get_cms_setting(name): ...
148
```
149
150
[Utilities](./utilities.md)
151
152
## Types
153
154
```python { .api }
155
class Page:
156
"""Core page model with tree structure and URL routing."""
157
158
class PageContent:
159
"""Versioned page content with language-specific data."""
160
161
class Placeholder:
162
"""Container for plugins within templates."""
163
164
class CMSPlugin:
165
"""Base model for all CMS plugins."""
166
167
class CMSPluginBase:
168
"""Base class for plugin implementations."""
169
```