Pages#

class cms.models.pagemodel.Page(*args, **kwargs)#

Bases: Model

A Page is the basic unit of site structure in django CMS. The CMS uses a hierarchical page model: each page stands in relation to other pages as parent, child or sibling. This hierarchy is managed by the django-treebeard library.

A Page also has language-specific properties - for example, it will have a title and a slug for each language it exists in. These properties are managed by the PageContent model.

copy_with_descendants(target_node=None, position=None, copy_permissions=True, target_site=None, user=None)#

Copy a page [ and all its descendants to a new location ]

get_application_urls(language=None, fallback=True, force_reload=False)#

get application urls conf for application hook

get_changed_by(language=None, fallback=True, force_reload=False)#

get user who last changed this page

get_changed_date(language=None, fallback=True, force_reload=False)#

get when this page was last updated

get_content_obj(language=None, fallback=True, force_reload=False)#

Helper function for accessing wanted / current title. If wanted title doesn’t exist, EmptyPageContent instance will be returned.

get_media_path(filename)#

Returns path (relative to MEDIA_ROOT/MEDIA_URL) to directory for storing page-scope files. This allows multiple pages to contain files with identical names without namespace issues. Plugins such as Picture can use this method to initialise the ‘upload_to’ parameter for File-based fields. For example:

image = models.ImageField(

_(“image”), upload_to=CMSPlugin.get_media_path)

where CMSPlugin.get_media_path calls self.page.get_media_path

This location can be customised using the CMS_PAGE_MEDIA_PATH setting

get_menu_title(language=None, fallback=True, force_reload=False)#

get the menu title of the page depending on the given language

get_meta_description(language=None, fallback=True, force_reload=False)#

get content for the description meta tag for the page depending on the given language

get_page_content_obj_attribute(attrname, language=None, fallback=True, force_reload=False)#

Helper function for getting attribute or None from wanted/current page content.

get_page_title(language=None, fallback=True, force_reload=False)#

get the page title of the page depending on the given language

get_path(language, fallback=True)#

Get the path of the page depending on the given language

get_redirect(language=None, fallback=True, force_reload=False)#

get redirect

get_template_name()#

get the textual name (2nd parameter in get_cms_setting(‘TEMPLATES’)) of the template of this page or of the nearest ancestor. failing to find that, return the name of the default template.

get_title(language=None, fallback=True, force_reload=False)#

get the title of the page depending on the given language

has_add_permission(user)#

Has user ability to add page under current page?

has_change_permissions_permission(user)#

Has user ability to change permissions for current page?

has_move_page_permission(user)#

Has user ability to move current page?

is_potential_home()#

Encapsulates logic for determining if this page is eligible to be set as is_home. This is a public method so that it can be accessed in the admin for determining whether to enable the “Set as home” menu item. :return: Boolean

move_page(target_node, position='first-child')#

Called from admin interface when page is moved. Should be used on all the places which are changing page position. Used like an interface to django-treebeard, but after move is done page_moved signal is fired.

Note for issue #1166: url conflicts are handled by updated check_title_slugs, overwrite_url on the moved page don’t need any check as it remains the same regardless of the page position in the tree

reload()#

Reload a page from the database

save(**kwargs)#

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

set_as_homepage(user=None)#

Sets the given page as the homepage. Updates the url paths for all affected pages. Returns the old home page (if any).

class cms.models.pagemodel.PageUrl(id, slug, path, language, page, managed)#

Bases: Model

class cms.models.pagemodel.PageType(id, created_by, changed_by, creation_date, changed_date, reverse_id, navigation_extenders, login_required, is_home, application_urls, application_namespace, languages, is_page_type, node)#

Bases: Page

is_potential_home()#

Encapsulates logic for determining if this page is eligible to be set as is_home. This is a public method so that it can be accessed in the admin for determining whether to enable the “Set as home” menu item. :return: Boolean

.