fluent_pages.integration.fluent_contents¶
The base classes to create a page which can display django-fluent-contents models.
The API to interface with django-fluent-contents is public, and documented for this reason.
In fact, this module is just a tiny bridge between the page type plugins and the django-fluent-pages API.
It can be used to create custom page types that display ContentItem objects.
The following parts are provided:
- The admin class;
admin.FluentContentsPageAdmin - The page type model:
models.FluentContentsPage - The plugin class:
page_type_plugins.FluentContentsPagePlugin
These classes can be imported from their respective subpackages:
from fluent_pages.integration.fluent_contents.admin import FluentContentsPageAdmin
from fluent_pages.integration.fluent_contents.models import FluentContentsPage
from fluent_pages.integration.fluent_contents.page_type_plugins import FluentContentsPagePlugin
The FluentContentsPageAdmin class¶
-
class
fluent_pages.integration.fluent_contents.admin.FluentContentsPageAdmin(model, admin_site, *args, **kwargs)¶ This admin is a small binding between the pagetypes of django-fluent-pages and page contents of django-fluent-contents.
Use
{% extends base_change_form_template %}in your page template, and it will all work properly.-
get_all_allowed_plugins()¶ By default, all plugins are allowed, unless a placeholder puts a limit on this. The page will load much faster if the plugin types are limited globally here.
-
get_placeholder_data(request, obj=None)¶ Read the placeholder data to display in the template. This reads
placeholder_layoutandplaceholder_layout_template. It can be overwritten to return the layout depending on the page or request.Tip: if the object is given, this could read
obj.plugin.get_render_template(request, obj)too.
-
get_translation_objects(request, language_code, obj=None, inlines=True)¶ Make sure the translated ContentItem objects are also deleted when a translation is removed.
-
all_allowed_plugins= None¶ A static list of all allowed plugin names. This is read by
get_all_allowed_plugins()
-
placeholder_layout= None¶ A fixed defined placeholder layout, which can be defined statically. This should be a list of
PlaceholderDataobjects.
-
placeholder_layout_template= None¶ A fixed template, from which the placeholder data can be read. The
placeholder_layoutwill be read automatically from the template.
-
The FluentContentsPage class¶
-
class
fluent_pages.integration.fluent_contents.models.FluentContentsPage(*args, **kwargs)¶ The base model to create a Page object which hosts placeholders and content items.
Parameters: - id (AutoField) – Id
- polymorphic_ctype (ForeignKey to
ContentType) – Polymorphic ctype - parent (PageTreeForeignKey to
UrlNode) – Parent. You can also change the parent by dragging the page in the list. - parent_site (ForeignKey to
Site) – Parent site - status (CharField) – Status
- publication_date (DateTimeField) – Publication date. When the page should go live, status must be “Published”.
- publication_end_date (DateTimeField) – Publication end date
- in_navigation (BooleanField) – Show in navigation
- in_sitemaps (BooleanField) – Include in search engine sitemaps
- key (SlugField) – Page identifier. A unique identifier that is used for linking to this page.
- author (ForeignKey to
User) – Author - creation_date (DateTimeField) – Creation date
- modification_date (DateTimeField) – Last modification
- lft (PositiveIntegerField) – Lft
- rght (PositiveIntegerField) – Rght
- tree_id (PositiveIntegerField) – Tree id
- level (PositiveIntegerField) – Level
- urlnode_ptr (OneToOneField to
UrlNode) – Urlnode ptr - placeholder_set (PlaceholderRelation) – Placeholder set
- contentitem_set (ContentItemRelation) – Contentitem set
-
create_placeholder(slot, role='m', title=None)¶ Create a placeholder on this page.
To fill the content items, use
ContentItemModel.objects.create_for_placeholder().Return type: Placeholder
-
get_content_items_by_slot(slot)¶ Return all content items of the page, which are stored in the given slot name. :rtype:
ContentItemQuerySet
-
get_placeholder_by_slot(slot)¶ Return a placeholder that is part of this page. :rtype:
Placeholder
-
contentitem_set¶ Model field: contentitem set, accesses the M2M
FluentContentsPagemodel.
-
placeholder_set¶ Model field: placeholder set, accesses the M2M
FluentContentsPagemodel.
The FluentContentsPagePlugin class¶
-
class
fluent_pages.integration.fluent_contents.page_type_plugins.FluentContentsPagePlugin¶ Base plugin to render a page with content items.
-
model_admin¶ alias of
fluent_pages.integration.fluent_contents.admin.FluentContentsPageAdmin
-
get_render_template(request, fluentpage, **kwargs)¶ Overwritten to automatically pick up the template used in the admin.
-
model= None¶ Defines the model to use to store the custom fields. It must derive from
FluentContentsPage.
-