2015-05-18 12:36:40 +02:00
Page model Reference
====================
2015-05-18 15:44:18 +02:00
`` Page `` Class Reference
~~~~~~~~~~~~~~~~~~~~~~~~
2015-05-18 16:08:28 +02:00
.. automodule :: wagtail.wagtailcore.models
.. autoclass :: Page
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
The following Django model fields are provided for all pages and are queryable from `` Page.objects `` .
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
.. attribute :: title (text)
2015-05-18 12:36:40 +02:00
2015-05-18 15:44:18 +02:00
Human-readable title of the page.
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
.. attribute :: slug (text)
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
The slug of the page. This is used for constructing the page's URL.
2015-05-18 15:44:18 +02:00
2015-05-18 16:08:28 +02:00
For example: `` http://domain.com/blog/[my-slug]/ ``
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
.. attribute :: content_type (foreign key)
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
A foreign key to the :class: `~django.contrib.contenttypes.models.ContentType` object that represents the specific model of this page.
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
.. attribute :: live (boolean)
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
A boolean that is set to `` True `` if the page is published.
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
Note: this field defaults to `` True `` meaning that any pages that are created programmatically will be published by default.
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
.. attribute :: has_unpublished_changes (boolean)
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
A boolean that is set to `` True `` when the page is either in draft or published with draft changes.
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
.. attribute :: owner (foreign key)
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
A foreign key to the user that created the page.
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
.. attribute :: first_published_at (date/time)
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
The date/time when the page was first published.
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
.. attribute :: seo_title (text)
2015-05-18 15:44:18 +02:00
2015-05-18 16:08:28 +02:00
Alternate SEO-crafted title, for use in the page's `` <title> `` HTML tag.
2015-05-18 15:44:18 +02:00
2015-05-18 16:08:28 +02:00
.. attribute :: search_description (text)
2015-05-18 15:44:18 +02:00
2015-05-18 16:08:28 +02:00
SEO-crafted description of the content, used for search indexing. This is also suitable for the page's `` <meta name="description"> `` HTML tag.
2015-05-18 15:44:18 +02:00
2015-05-18 16:08:28 +02:00
.. attribute :: show_in_menus (boolean)
2015-05-18 15:44:18 +02:00
2015-05-18 16:08:28 +02:00
Toggles whether the page should be included in site-wide menus.
2015-05-18 15:44:18 +02:00
2015-05-18 16:08:28 +02:00
This is used by the :meth: `~wagtail.wagtailcore.query.PageQuerySet.in_menu` QuerySet filter.
2015-05-18 12:36:40 +02:00
2015-05-18 16:08:28 +02:00
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. Those listed here are relatively straightforward to use, but consult the Wagtail source code for a full view of what's possible.
2015-02-19 17:53:24 +01:00
.. autoattribute :: specific
.. autoattribute :: specific_class
.. autoattribute :: url
.. autoattribute :: full_url
.. automethod :: get_verbose_name
.. automethod :: relative_url
.. automethod :: is_navigable
.. automethod :: route
.. automethod :: serve
.. automethod :: get_context
.. automethod :: get_template
.. autoattribute :: preview_modes
.. automethod :: serve_preview
.. automethod :: get_ancestors
.. automethod :: get_descendants
.. automethod :: get_siblings
.. automethod :: search
.. attribute :: search_fields
A list of fields to be indexed by the search engine. See Search docs :ref: `wagtailsearch_indexing_fields`
.. attribute :: subpage_types
A whitelist of page models which can be created as children of this page type e.g a `` BlogIndex `` page might allow `` BlogPage `` , but not `` JobPage `` e.g
.. code-block :: python
class BlogIndex(Page):
subpage_types = ['mysite.BlogPage', 'mysite.BlogArchivePage']
2015-02-21 11:05:41 +01:00
The creation of child pages can be blocked altogether for a given page by setting it's subpage_types attribute to an empty array e.g
.. code-block :: python
class BlogPage(Page):
subpage_types = []
.. attribute :: parent_page_types
A whitelist of page models which are allowed as parent page types e.g a `` BlogPage `` may only allow itself to be created below the `` BlogIndex `` page e.g
.. code-block :: python
class BlogPage(Page):
parent_page_types = ['mysite.BlogIndexPage']
Pages can block themselves from being created at all by setting parent_page_types to an empty array (this is useful for creating unique pages that should only be created once) e.g
.. code-block :: python
class HiddenPage(Page):
parent_page_types = []
2015-02-19 17:53:24 +01:00
.. attribute :: password_required_template
Defines which template file should be used to render the login form for Protected pages using this model. This overrides the default, defined using `` PASSWORD_REQUIRED_TEMPLATE `` in your settings. See :ref: `private_pages`
2015-05-18 12:36:40 +02:00
Other models
------------
`` Site ``
~~~~~~~~
.. autoclass :: Site
.. automethod :: find_for_request
.. autoattribute :: root_url
.. automethod :: get_site_root_paths
`` PageRevision ``
~~~~~~~~~~~~~~~~
.. autoclass :: PageRevision
.. automethod :: as_page_object
.. automethod :: approve_moderation
.. automethod :: reject_moderation
.. automethod :: is_latest_revision
.. automethod :: publish
`` GroupPagePermission ``
~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass :: GroupPagePermission
`` PageViewRestriction ``
~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass :: PageViewRestriction
`` Orderable `` (abstract)
~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass :: Orderable