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.
PageIn 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.
SiteThe 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.
LocaleThe 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.
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.
TranslatableMixinTranslatableMixin 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.
The locale and translation_key fields have a unique key constraint to prevent the object being translated into a language more than once.
PreviewableMixinPreviewableMixin 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.
RevisionMixinRevisionMixin 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.
DraftStateMixinDraftStateMixin 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.
RevisionEvery 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.
RevisionMixin by calling its save_revision() method.content field.Revision as an instance of the object’s model by calling the as_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.
GroupPagePermissionPageViewRestrictionOrderable (abstract)WorkflowWorkflows represent sequences of tasks which much be approved for an action to be performed on a page - typically publication.
WorkflowStateWorkflow states represent the status of a started workflow on a page.
TaskTasks represent stages in a workflow which must be approved for the workflow to complete successfully.
TaskStateTask states store state information about the progress of a task on a particular page revision.
WorkflowTaskRepresents the ordering of a task in a specific workflow.
WorkflowPageRepresents the assignment of a workflow to a page and its descendants.
BaseLogEntryAn abstract base class that represents a record of an action performed on an object.
PageLogEntryRepresents a record of an action performed on an Page, subclasses BaseLogEntry.
CommentRepresents a comment on a page.
CommentReplyRepresents a reply to a comment thread.
PageSubscriptionRepresents a user’s subscription to email notifications about page events. Currently only used for comment notifications.
© 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