Table Of Contents

Previous topic

Design

Next topic

Template structure

This Page

Database Models

At the heart of the Content Management System lays the djpcms.models.Page and djpcms.models.BlockContent database models. A page, or better, the djpcms.models.Page.inner_template field is a container for one or several blocks, and each block has one or several contents. The number of blocks within a page is specified in by the djpcms.models.InnerTemplate.numblocks method.

Page Model

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

The page model holds several information regarding pages in the sitemap.

site

Site to which the page belongs.

application_view

Name of the djpcms.views.appview.AppViewBase owner of the page. It can be empty, in which case the page is a flat page (not part of an application).

inner_template

Page inner template is an instance of djpcms.models.InnerTemplate. It contains information regrading the number of blocks in the page as well as the layout structure.

template

Optional template file for rendering the page. If not specified the DEFAULT_TEMPLATE_NAME is used.

in_navigation

Integer flag indicating positioning in the site navigation (see djpcms.utils.navigation.Navigator). If set to 0 the page won’t be displayed in the navigation.

parent

Parent page. If None the page is the site root page.

application

Name of the djpcms.views.appsite.ApplicationBase owner of the page. It can be empty, in which case the page is a flat page (not part of an application).

get_template()

Returns the name of the HTML template file for the page. If not specified we get the template of the parent page.

Block Content Model

class djpcms.models.BlockContent(*args, **kwargs)

A block content object is responsible storing djpcms.plugins.DJPplugin and for maintaining their position in a djpcms.models.Page.

page

djpcms.models.Page holding self.

block

Integer indicating the block number within the page.

position

Integer indicationg the position of content within the content block.

plugin_name

The unique djpcms.plugins.DJPplugin.name of plugin in the content block.

arguments

djpcms.plugins.DJPplugin arguments as JSON string.

container_type

The unique djpcms.plugins.DJPwrapper.name of the plugin html-wrapper.

title

Optional title

for_not_authenticated

If True (default is False) the block will be rendered only for non-authenticated users.

requires_login

If True (default is False) the block will be rendered only for authenticated users.

plugin_class()

utility functions. Return the class of the embedded plugin (if available) otherwise it returns Null

render(djp, plugin=None, wrapper=None)

Render the plugin. This function call the plugin render function

change_plugin_content(request)

Handle a POST request when changing app_page

Inner Template Model

class djpcms.models.InnerTemplate(*args, **kwargs)

Page Inner template

render(c)

Render the inner template given the context c.

numblocks()

Number of blocks within template.

SiteContent Model

class djpcms.models.SiteContent(*args, **kwargs)

Store content for your web site. It can store markup or raw HTML.

markup

Markup type. If not specified it will be treated as raw HTML.

Object Permission

class djpcms.models.ObjectPermission(*args, **kwargs)

Model for handling per-object permissions. An object which has at least one of this model instances associated with, will have permissions handled by this model only.

content

Provides a generic relation to any object through content-type/object-id fields.

has_perm(user)

Check permission for user