- Import necessary modules and classes:
from cms.api import create_page
from cms.models import Page
from django.contrib.auth.models import User
- Define necessary variables and parameters, such as title, template, language, and parent page:
title = "Your Page Title"
template = "your_template.html"
language = "en"
parent_page = Page.objects.all().first() # Assuming you have an existing parent page
created_by = User.objects.first() # Assuming you have an existing user
- Create the page programmatically using the
create_page
method, passing in the defined parameters:
new_page = create_page(
title,
template,
language,
created_by,
parent=parent_page,
published=True
)