or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.mdmenus.mdpages.mdpermissions.mdplugins.mdtemplates.mdutilities.md

pages.mddocs/

0

# Page and Content Management

1

2

Django CMS provides comprehensive page management functionality for creating, organizing, and managing hierarchical content structures with full multi-language support and versioning capabilities.

3

4

## Capabilities

5

6

### Page Creation and Management

7

8

Create and manage CMS pages with hierarchical structure, template assignment, and comprehensive configuration options.

9

10

```python { .api }

11

def create_page(

12

title,

13

template,

14

language,

15

menu_title=None,

16

slug=None,

17

apphook=None,

18

apphook_namespace=None,

19

redirect=None,

20

meta_description=None,

21

created_by="python-api",

22

parent=None,

23

publication_date=None,

24

publication_end_date=None,

25

in_navigation=False,

26

soft_root=False,

27

reverse_id=None,

28

navigation_extenders=None,

29

published=None,

30

site=None,

31

login_required=False,

32

limit_visibility_in_menu=None,

33

position="last-child",

34

overwrite_url=None,

35

xframe_options=None

36

):

37

"""

38

Create a new CMS page.

39

40

Args:

41

title (str): Page title

42

template (str): Template identifier

43

language (str): Language code

44

menu_title (str, optional): Navigation menu title

45

slug (str, optional): URL slug, auto-generated if None

46

apphook (str|CMSApp, optional): Application hook configuration

47

apphook_namespace (str, optional): App hook namespace

48

redirect (str, optional): Redirect URL

49

meta_description (str, optional): SEO meta description

50

created_by (str): Creator identifier

51

parent (Page, optional): Parent page for hierarchy

52

publication_date (datetime, optional): Publication start date

53

publication_end_date (datetime, optional): Publication end date

54

in_navigation (bool): Include in navigation menus

55

soft_root (bool): Act as navigation root

56

reverse_id (str, optional): Unique reverse ID for lookups

57

navigation_extenders (str, optional): Navigation extender class

58

published (bool, optional): Publish immediately

59

site (Site, optional): Django site, uses current if None

60

login_required (bool): Require login to view page

61

limit_visibility_in_menu (int, optional): Menu visibility limit

62

position (str): Position relative to siblings

63

overwrite_url (str, optional): Custom URL override

64

xframe_options (int, optional): X-Frame-Options header setting

65

66

Returns:

67

Page: Created page instance

68

"""

69

70

def get_page_draft(page):

71

"""

72

Get the draft version of a page.

73

74

Args:

75

page (Page): Page instance

76

77

Returns:

78

Page: Draft version of the page

79

"""

80

```

81

82

### Page Content Management

83

84

Manage versioned page content with language-specific data and publishing workflow.

85

86

```python { .api }

87

def create_page_content(

88

language,

89

title,

90

page,

91

slug=None,

92

path=None,

93

redirect=None,

94

in_navigation=True,

95

limit_visibility_in_menu=None,

96

**kwargs

97

):

98

"""

99

Create page content for specific language.

100

101

Args:

102

language (str): Language code

103

title (str): Content title

104

page (Page): Target page

105

slug (str, optional): URL slug

106

path (str, optional): Full URL path

107

redirect (str, optional): Redirect URL

108

in_navigation (bool): Show in navigation

109

limit_visibility_in_menu (int, optional): Menu visibility limit

110

111

Returns:

112

PageContent: Created page content instance

113

"""

114

115

def create_title(title, language, page, slug=None, path=None):

116

"""

117

Create page title (deprecated - use create_page_content).

118

119

Args:

120

title (str): Page title

121

language (str): Language code

122

page (Page): Target page

123

slug (str, optional): URL slug

124

path (str, optional): URL path

125

126

Returns:

127

PageContent: Page content instance

128

"""

129

```

130

131

### Publishing and Workflow

132

133

**Note**: Publishing functionality has been removed from Django CMS core in version 4+. For publishing capabilities, use additional packages like `djangocms-versioning`.

134

135

The core API no longer includes `publish_page` or `publish_pages` functions. These functions now only emit warnings and do not perform any publishing operations.

136

137

### Multi-language Content Management

138

139

Handle content translation and cross-language operations.

140

141

```python { .api }

142

def copy_plugins_to_language(page, source_language, target_language, only_empty=True):

143

"""

144

Copy page plugins between languages.

145

146

Args:

147

page (Page): Target page

148

source_language (str): Source language code

149

target_language (str): Target language code

150

only_empty (bool): Only copy to empty placeholders

151

152

Returns:

153

bool: Success status

154

"""

155

```

156

157

## Usage Examples

158

159

### Creating a Page Hierarchy

160

161

```python

162

from cms.api import create_page

163

164

# Create parent page

165

home_page = create_page(

166

title="Home",

167

template="homepage.html",

168

language="en",

169

slug="", # Root page

170

published=True,

171

in_navigation=True

172

)

173

174

# Create child page

175

about_page = create_page(

176

title="About Us",

177

template="page.html",

178

language="en",

179

parent=home_page,

180

published=True

181

)

182

183

# Create grandchild page

184

team_page = create_page(

185

title="Our Team",

186

template="page.html",

187

language="en",

188

parent=about_page,

189

reverse_id="team" # For easy lookups

190

)

191

```

192

193

### Multi-language Page Setup

194

195

```python

196

# Create English page

197

page = create_page(

198

title="Welcome",

199

template="page.html",

200

language="en",

201

slug="welcome"

202

)

203

204

# Add German translation

205

german_content = create_page_content(

206

page=page,

207

language="de",

208

title="Willkommen",

209

slug="willkommen"

210

)

211

212

# Add French translation

213

french_content = create_page_content(

214

page=page,

215

language="fr",

216

title="Bienvenue",

217

slug="bienvenue"

218

)

219

220

# Note: Publishing has been removed from core Django CMS.

221

# Use djangocms-versioning or similar packages for publishing functionality.

222

```

223

224

### Working with Page Models

225

226

```python

227

from cms.models import Page, PageContent

228

229

# Get page by reverse ID

230

page = Page.objects.get(reverse_id="team")

231

232

# Get all page content versions

233

content_versions = page.pagecontent_set.all()

234

235

# Get specific language content

236

english_content = page.get_content_obj(language="en")

237

238

# Check if page is published

239

is_published = page.is_published("en")

240

241

# Get page URL

242

page_url = page.get_absolute_url(language="en")

243

```

244

245

## Types

246

247

```python { .api }

248

class Page:

249

"""

250

Core page model with hierarchical structure.

251

252

Attributes:

253

node: TreeNode for hierarchy management

254

reverse_id: Optional unique identifier

255

navigation_extenders: Navigation extension class

256

is_home: Whether this is the site home page

257

application_urls: App hook configuration

258

application_namespace: App namespace

259

"""

260

261

def get_absolute_url(self, language=None):

262

"""Get page URL for language."""

263

264

def get_content_obj(self, language=None, fallback=True):

265

"""Get PageContent for language."""

266

267

def is_published(self, language):

268

"""Check if page is published in language."""

269

270

def get_placeholders(self, language):

271

"""Get page placeholders for language."""

272

273

class PageContent:

274

"""

275

Language-specific page content with versioning.

276

277

Attributes:

278

page: Associated Page instance

279

language: Language code

280

title: Page title

281

slug: URL slug

282

path: Full URL path

283

redirect: Redirect URL

284

in_navigation: Navigation visibility

285

limit_visibility_in_menu: Menu visibility limit

286

meta_description: SEO meta description

287

page_title: HTML page title

288

menu_title: Navigation menu title

289

"""

290

291

def get_absolute_url(self):

292

"""Get content URL."""

293

294

def get_placeholders(self):

295

"""Get associated placeholders."""

296

```