On this page
Model Reference
wagtail.models is split into submodules for maintainability. All definitions intended as public should be imported here (with ‘noqa’ comments as required) and outside code should continue to import them from wagtail.models (e.g. from wagtail.models import Site
, not from wagtail.models.sites import Site
.)
Submodules should take care to keep the direction of dependencies consistent; where possible they should implement low-level generic functionality which is then imported by higher-level models such as Page.
This document contains reference information for the model classes inside the wagtailcore
module.
Page
Database fields
Methods and properties
In addition to the model fields provided, Page
has many properties and methods that you may wish to reference, use, or override in creating your own models.
Note
See also django-treebeard’s `node API https://django-treebeard.readthedocs.io/en/latest/api.html. Page
is a subclass of materialized path tree nodes.
Site
The Site
model is useful for multi-site installations as it allows an administrator to configure which part of the tree to use for each hostname that the server responds on.
The find_for_request()
function returns the Site object that will handle the given HTTP request.
Database fields
Methods and properties
Locale
The Locale
model defines the set of languages and/or locales that can be used on a site. Each Locale
record corresponds to a “language code” defined in the :ref:wagtail_content_languages_setting
setting.
Wagtail will initially set up one Locale
to act as the default language for all existing content. This first locale will automatically pick the value from WAGTAIL_CONTENT_LANGUAGES
that most closely matches the site primary language code defined in LANGUAGE_CODE
. If the primary language code is changed later, Wagtail will not automatically create a new Locale
record or update an existing one.
Before internationalisation is enabled, all pages use this primary Locale
record. This is to satisfy the database constraints, and makes it easier to switch internationalisation on at a later date.
Changing WAGTAIL_CONTENT_LANGUAGES
Languages can be added or removed from WAGTAIL_CONTENT_LANGUAGES
over time.
Before removing an option from WAGTAIL_CONTENT_LANGUAGES
, it’s important that the Locale
record is updated to a use a different content language or is deleted. Any Locale
instances that have invalid content languages are automatically filtered out from all database queries making them unable to be edited or viewed.
Methods and properties
TranslatableMixin
TranslatableMixin
is an abstract model that can be added to any non-page Django model to make it translatable. Pages already include this mixin, so there is no need to add it.
Database fields
The locale
and translation_key
fields have a unique key constraint to prevent the object being translated into a language more than once.
Methods and properties
PreviewableMixin
PreviewableMixin
is a mixin class that can be added to any non-page Django model to allow previewing its instances. Pages already include this mixin, so there is no need to add it.
New in version 4.0: The class is added to allow snippets to have live preview in the editor. See Making snippets previewable for more details.
Methods and properties
RevisionMixin
RevisionMixin
is an abstract model that can be added to any non-page Django model to allow saving revisions of its instances. Pages already include this mixin, so there is no need to add it.
New in version 4.0: The model is added to allow snippets to save revisions, revert to a previous revision, and compare changes between revisions. See Saving revisions of snippets for more details.
Database fields
Methods and properties
DraftStateMixin
DraftStateMixin
is an abstract model that can be added to any non-page Django model to allow its instances to have unpublished changes. This mixin requires RevisionMixin
to be applied. Pages already include this mixin, so there is no need to add it.
New in version 4.0: The model is added to allow snippets to have changes that are not immediately reflected to the instance. See Saving draft changes of snippets for more details.
Database fields
Methods and properties
Revision
Every time a page is edited, a new Revision
is created and saved to the database. It can be used to find the full history of all changes that have been made to a page and it also provides a place for new changes to be kept before going live.
- Revisions can be created from any instance of
RevisionMixin
by calling itssave_revision()
method. - The content of the page is JSON-serialisable and stored in the
content
field. - You can retrieve a
Revision
as an instance of the object’s model by calling theas_object()
method.
Changed in version 4.0: The model has been renamed from PageRevision
to Revision
and it now references the Page
model using a GenericForeignKey
.
Database fields
Managers
Methods and properties
GroupPagePermission
Database fields
PageViewRestriction
Database fields
Orderable
(abstract)
Database fields
Workflow
Workflows represent sequences of tasks which much be approved for an action to be performed on a page - typically publication.
Database fields
Methods and properties
WorkflowState
Workflow states represent the status of a started workflow on a page.
Database fields
Methods and properties
Task
Tasks represent stages in a workflow which must be approved for the workflow to complete successfully.
Database fields
Methods and properties
TaskState
Task states store state information about the progress of a task on a particular page revision.
Database fields
Methods and properties
WorkflowTask
Represents the ordering of a task in a specific workflow.
Database fields
WorkflowPage
Represents the assignment of a workflow to a page and its descendants.
Database fields
BaseLogEntry
An abstract base class that represents a record of an action performed on an object.
Database fields
Methods and properties
PageLogEntry
Represents a record of an action performed on an Page
, subclasses BaseLogEntry
.
Database fields
Comment
Represents a comment on a page.
Database fields
CommentReply
Represents a reply to a comment thread.
Database fields
PageSubscription
Represents a user’s subscription to email notifications about page events. Currently only used for comment notifications.
Database fields
© 2014-present Torchbox Ltd and individual contributors.
All rights are reserved.
Licensed under the BSD License.
https://docs.wagtail.org/en/stable/reference/pages/model_reference.html