10.1. Base models

10.1.1. Base

class feincms.models.Base(*args, **kwargs)

This is the base class for your CMS models.

class Base.Meta
Base.content

Provide a simple interface for getting all content blocks for a region.

Base.content_proxy_class

alias of ContentProxy

classmethod Base.content_type_for(model)

Return the concrete content type for an abstract content type:

from feincms.content.video.models import VideoContent
concrete_type = Page.content_type_for(VideoContent)
Base.copy_content_from(obj)

Copy all content blocks over to another CMS base object. (Must be of the same type, but this is not enforced. It will crash if you try to copy content from another CMS base type.)

classmethod Base.create_content_type(model, regions=None, **kwargs)

This is the method you’ll use to create concrete content types.

If the CMS base class is page.models.Page, its database table will be page_page. A concrete content type which is created from ImageContent will use page_page_imagecontent as its table.

If you want a content type only available in a subset of regions, you can pass a list/tuple of region keys as regions. The content type will only appear in the corresponding tabs in the item editor.

You can pass additional keyword arguments to this factory function. These keyword arguments will be passed on to the concrete content type, provided that it has a initialize_type classmethod. This is used f.e. in MediaFileContent to pass a set of possible media positions (f.e. left, right, centered) through to the content type.

classmethod Base.register_extension(register_fn)

Call the register function of an extension. You must override this if you provide a custom ModelAdmin class and want your extensions to be able to patch stuff in.

classmethod Base.register_extensions(*extensions)
classmethod Base.register_regions(*regions)

Register a list of regions. Only use this if you do not want to use multiple templates with this model (read: not use register_templates):

BlogEntry.register_regions(
    ('main', _('Main content area')),
    )
classmethod Base.register_templates(*templates)

Register templates and add a template_key field to the model for saving the selected template:

Page.register_templates({
    'key': 'base',
    'title': _('Standard template'),
    'path': 'feincms_base.html',
    'regions': (
        ('main', _('Main content area')),
        ('sidebar', _('Sidebar'), 'inherited'),
        ),
    }, {
    'key': '2col',
    'title': _('Template with two columns'),
    'path': 'feincms_2col.html',
    'regions': (
        ('col1', _('Column one')),
        ('col2', _('Column two')),
        ('sidebar', _('Sidebar'), 'inherited'),
        ),
    })
Base.replace_content_with(obj)

10.1.2. Template

class feincms.models.Template(title, path, regions, key=None, preview_image=None)

A template is a standard Django template which is used to render a CMS object, most commonly a page.

10.1.3. Region

class feincms.models.Region(key, title, *args)

This class represents a region inside a template. Example regions might be ‘main’ and ‘sidebar’.

Region.content_types

Returns a list of content types registered for this region as a list of (content type key, beautified content type name) tuples

10.1.4. ContentProxy

class feincms.models.ContentProxy(item)

This proxy offers attribute-style access to the page contents of regions:

>> page = Page.objects.all()[0]
>> page.content.main
[A list of all page contents which are assigned to the region with key 'main']
ContentProxy.get_content(item, attr)

Table Of Contents

Previous topic

10. API documentation

Next topic

10.2. Page module

This Page