Page reference API

Page Model

class pages.models.Page(*args, **kwargs)

This model contain the status, dates, author, template. The real content of the page can be found in the Content model.

DoesNotExist()
MultipleObjectsReturned()
author
calculated_status
get the calculated status of the page based on published_date, published_end_date, and status.
children
content_set
delete()
get_absolute_url(*moreargs, **morekwargs)
get_ancestors(ascending=False)

Creates a QuerySet containing the ancestors of this model instance.

This defaults to being in descending order (root ancestor first, immediate parent last); passing True for the ascending argument will reverse the ordering (immediate parent first, root ancestor last).

get_calculated_status()
get the calculated status of the page based on published_date, published_end_date, and status.
get_children()

Creates a QuerySet containing the immediate children of this model instance, in tree order.

The benefit of using this method over the reverse relation provided by the ORM to the instance’s children is that a database query can be avoided in the case where the instance is a leaf node (it has no children).

get_children_for_frontend()
Creates a QuerySet of published children page
get_descendant_count()
Returns the number of descendants this model instance has.
get_descendants(include_self=False)

Creates a QuerySet containing descendants of this model instance, in tree order.

If include_self is True, the QuerySet will also include this model instance.

get_languages()
Return a list of all existing languages for this page.
get_next_by_creation_date(*moreargs, **morekwargs)
get_next_by_last_modification_date(*moreargs, **morekwargs)
get_next_sibling()
Returns this model instance’s next sibling in the tree, or None if it doesn’t have a next sibling.
get_previous_by_creation_date(*moreargs, **morekwargs)
get_previous_by_last_modification_date(*moreargs, **morekwargs)
get_previous_sibling()
Returns this model instance’s previous sibling in the tree, or None if it doesn’t have a previous sibling.
get_root()
Returns the root node of this model instance’s tree.
get_siblings(include_self=False)

Creates a QuerySet containing siblings of this model instance. Root nodes are considered to be siblings of other root nodes.

If include_self is True, the QuerySet will also include this model instance.

get_status_display(*moreargs, **morekwargs)
get_template()
get the template of this page if defined or if closer parent if defined or DEFAULT_PAGE_TEMPLATE otherwise
get_template_name()
get_url(language=None)
Return url of this page, adding all parent’s slug.
has_page_permission(request)
Return true if the current user has permission on the page. Return the string ‘All’ if the user has all rights.
insert_at(target, position='first-child', commit=False)
Convenience method for calling TreeManager.insert_node with this model instance.
invalidate(language_code=None)
Invalidate this page and it’s descendants.
is_child_node()
Returns True if this model instance is a child node, False otherwise.
is_leaf_node()
Returns True if this model instance is a leaf node (it has no children), False otherwise.
is_root_node()
Returns True if this model instance is a root node, False otherwise.
margin_level()
move_to(target, position='first-child')
Convenience method for calling TreeManager.move_node with this model instance.
objects
Page manager provide several filters to obtain pages QuerySet that respect the page settings.
pagealias_set
pagepermission_set
parent
redirect_to
redirected_pages
save(*args, **kwargs)
Override the save method.
sites
slug(language=None, fallback=True)

Return the slug of the page depending on the given language.

If fallback is True, the slug will also be searched in other languages.

title(language=None, fallback=True)

Return the title of the page depending on the given language.

If fallback is True, the title will also be searched in other languages.

traductions()
tree
A manager for working with trees of objects.
valid_targets(perms='All')
Return a QuerySet of valid targets for moving a page into the tree.
with_level()
Display the slug of the page prepended with insecable spaces equal to the level of page in the hierarchy.

Page Manager

class pages.managers.PageManager

Page manager provide several filters to obtain pages QuerySet that respect the page settings.

drafts()
Creates a QuerySet of drafts using the page’s status and publication_date.
expired()
filter_published(queryset)
Filter the given pages QuerySet to obtain only published page.
from_path(path, lang, exclude_drafts=True)
Get a page according to the page’s path.
hidden()
Creates a QuerySet of the hidden pages.
navigation()
Creates a QuerySet of the published root pages.
on_site(site_id=None)
Return a QuerySet of pages that are published on the site defined by the SITE_ID setting.
published()
Creates a QuerySet of published filter.
root()
Return a QuerySet of pages without parent.

Content Model

class pages.models.Content(*args, **kwargs)

A block of content, tied to a page, for a particular language

DoesNotExist()
MultipleObjectsReturned()
get_next_by_creation_date(*moreargs, **morekwargs)
get_previous_by_creation_date(*moreargs, **morekwargs)
objects
Content manager methods
page

Content Manager

class pages.managers.ContentManager

Content manager methods

create_content_if_changed(page, language, cnttype, body)
Set or create a content for a particular page and language
get_content(page, language, ctype, language_fallback=False)
Gets the latest Content for a particular page and language. Falls back to another language if wanted.
get_content_slug_by_slug(slug)
Returns the latest Content slug object that match the given slug for the current site domain.
get_page_ids_by_slug(slug)
Return all page id matching the given slug.
sanitize(content)
Sanitize the content to avoid XSS
set_or_create_content(page, language, cnttype, body)
Set or create a content for a particular page and language.

PageAlias Model

class pages.models.PageAlias(*args, **kwargs)

URL alias for a page

DoesNotExist()
MultipleObjectsReturned()
objects
PageAlias manager.
page
save(*args, **kwargs)

PageAlias Manager

class pages.managers.PageAliasManager

PageAlias manager.

get_for_url(request, path=None, lang=None)
Resolve a request to an alias. returns a PageAlias object or None if the url matches no page at all. The aliasing system supports plain aliases (/foo/bar) as well as aliases containing GET parameters (like index.php?page=foo).

PagePermission Model

class pages.models.PagePermission(*args, **kwargs)

Page permission object

DoesNotExist()
MultipleObjectsReturned()
get_type_display(*moreargs, **morekwargs)
objects
Hierachic page permission manager.
page
user

PagePermission Manager

class pages.managers.PagePermissionManager

Hierachic page permission manager.

get_page_id_list(user)
Give a list of Page ids where the user has rights or the string “All” if the user has all rights.

Utils

A collection of functions for Page CMS

pages.utils.get_placeholders(template_name)
Return a list of PlaceholderNode found in the given template
pages.utils.has_page_add_permission(request, page=None)
Return true if the current user has permission to add a new page.
pages.utils.normalize_url(url)

Return a normalized url with trailing and without leading slash.

>>> normalize_url(None)
'/'
>>> normalize_url('/')
'/'
>>> normalize_url('/foo/bar')
'/foo/bar'
>>> normalize_url('foo/bar')
'/foo/bar'
>>> normalize_url('/foo/bar/')
'/foo/bar'
pages.utils.placeholders_recursif(nodelist, plist, blist)
Recursively search into a template node list for PlaceholderNode node.

Http

Page CMS functions related to the request object.

exception pages.http.AutoRenderHttpError
Cannot return context dictionary because a view returned an HTTP response when a (template_name, context) tuple was expected.
pages.http.auto_render(func)
This view decorator automatically calls the render_to_response shortcut. A view that use this decorator should return a tuple of this form : (template name, context) instead of a HttpRequest object.
pages.http.get_language_from_request(request, current_page=None)
Return the most obvious language according the request.
pages.http.get_request_mock()
Build a request mock that can be used for testing.
pages.http.get_slug_and_relative_path(path)
Split a page path into the slug, and the remaining left part.
pages.http.get_template_from_request(request, page=None)
Gets a valid template from different sources or falls back to the default template.