model_reference.rst 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  1. ===============
  2. Model Reference
  3. ===============
  4. .. automodule:: wagtail.models
  5. This document contains reference information for the model classes inside the ``wagtailcore`` module.
  6. .. _page-model-ref:
  7. ``Page``
  8. ========
  9. Database fields
  10. ~~~~~~~~~~~~~~~
  11. .. class:: Page
  12. .. attribute:: title
  13. (text)
  14. Human-readable title of the page.
  15. .. attribute:: draft_title
  16. (text)
  17. Human-readable title of the page, incorporating any changes that have been made in a draft edit (in contrast to the ``title`` field, which for published pages will be the title as it exists in the current published version).
  18. .. attribute:: slug
  19. (text)
  20. This is used for constructing the page's URL.
  21. For example: ``http://domain.com/blog/[my-slug]/``
  22. .. attribute:: content_type
  23. (foreign key to ``django.contrib.contenttypes.models.ContentType``)
  24. A foreign key to the :class:`~django.contrib.contenttypes.models.ContentType` object that represents the specific model of this page.
  25. .. attribute:: live
  26. (boolean)
  27. A boolean that is set to ``True`` if the page is published.
  28. Note: this field defaults to ``True`` meaning that any pages that are created programmatically will be published by default.
  29. .. attribute:: has_unpublished_changes
  30. (boolean)
  31. A boolean that is set to ``True`` when the page is either in draft or published with draft changes.
  32. .. attribute:: owner
  33. (foreign key to user model)
  34. A foreign key to the user that created the page.
  35. .. attribute:: first_published_at
  36. (date/time)
  37. The date/time when the page was first published.
  38. .. attribute:: last_published_at
  39. (date/time)
  40. The date/time when the page was last published.
  41. .. attribute:: seo_title
  42. (text)
  43. Alternate SEO-crafted title, for use in the page's ``<title>`` HTML tag.
  44. .. attribute:: search_description
  45. (text)
  46. SEO-crafted description of the content, used for search indexing. This is also suitable for the page's ``<meta name="description">`` HTML tag.
  47. .. attribute:: show_in_menus
  48. (boolean)
  49. Toggles whether the page should be included in site-wide menus, and is shown in the ``promote_panels`` within the Page editor.
  50. Wagtail does not include any menu implementation by default, which means that this field will not do anything in the front facing content unless built that way in a specific Wagtail installation.
  51. However, this is used by the :meth:`~wagtail.query.PageQuerySet.in_menu` QuerySet filter to make it easier to query for pages that use this field.
  52. Defaults to ``False`` and can be overridden on the model with ``show_in_menus_default = True``.
  53. .. note::
  54. To set the global default for all pages, set ``Page.show_in_menus_default = True`` once where you first import the ``Page`` model.
  55. .. attribute:: locked
  56. (boolean)
  57. When set to ``True``, the Wagtail editor will not allow any users to edit
  58. the content of the page.
  59. If ``locked_by`` is also set, only that user can edit the page.
  60. .. attribute:: locked_by
  61. (foreign key to user model)
  62. The user who has currently locked the page. Only this user can edit the page.
  63. If this is ``None`` when ``locked`` is ``True``, nobody can edit the page.
  64. .. attribute:: locked_at
  65. (date/time)
  66. The date/time when the page was locked.
  67. .. attribute:: alias_of
  68. (foreign key to another page)
  69. If set, this page is an alias of the page referenced in this field.
  70. .. attribute:: locale
  71. (foreign key to Locale)
  72. This foreign key links to the ``Locale`` object that represents the page language.
  73. .. attribute:: translation_key
  74. (uuid)
  75. A UUID that is shared between translations of a page. These are randomly generated
  76. when a new page is created and copied when a translation of a page is made.
  77. A translation_key value can only be used on one page in each locale.
  78. Methods and properties
  79. ~~~~~~~~~~~~~~~~~~~~~~
  80. 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.
  81. .. note::
  82. See also `django-treebeard <https://django-treebeard.readthedocs.io/en/latest/index.html>`_'s `node API <https://django-treebeard.readthedocs.io/en/latest/api.html>`_. ``Page`` is a subclass of `materialized path tree <https://django-treebeard.readthedocs.io/en/latest/mp_tree.html>`_ nodes.
  83. .. class:: Page
  84. :noindex:
  85. .. automethod:: get_specific
  86. .. autoattribute:: specific
  87. .. autoattribute:: specific_deferred
  88. .. autoattribute:: specific_class
  89. .. autoattribute:: cached_content_type
  90. .. automethod:: get_url
  91. .. automethod:: get_full_url
  92. .. autoattribute:: full_url
  93. .. automethod:: relative_url
  94. .. automethod:: get_site
  95. .. automethod:: get_url_parts
  96. .. automethod:: route
  97. .. automethod:: serve
  98. .. autoattribute:: context_object_name
  99. Custom name for page instance in page's ``Context``.
  100. .. automethod:: get_context
  101. .. automethod:: get_template
  102. .. automethod:: get_admin_display_title
  103. .. autoattribute:: preview_modes
  104. .. automethod:: serve_preview
  105. .. automethod:: get_parent
  106. .. automethod:: get_ancestors
  107. .. automethod:: get_descendants
  108. .. automethod:: get_siblings
  109. .. automethod:: get_translations
  110. .. automethod:: get_translation
  111. .. automethod:: get_translation_or_none
  112. .. automethod:: has_translation
  113. .. automethod:: copy_for_translation
  114. .. autoattribute:: localized
  115. .. autoattribute:: localized_draft
  116. .. attribute:: search_fields
  117. A list of fields to be indexed by the search engine. See Search docs :ref:`wagtailsearch_indexing_fields`
  118. .. attribute:: subpage_types
  119. A list of page models which can be created as children of this page type. For example, a ``BlogIndex`` page might allow a ``BlogPage`` as a child, but not a ``JobPage``:
  120. .. code-block:: python
  121. class BlogIndex(Page):
  122. subpage_types = ['mysite.BlogPage', 'mysite.BlogArchivePage']
  123. The creation of child pages can be blocked altogether for a given page by setting its subpage_types attribute to an empty array:
  124. .. code-block:: python
  125. class BlogPage(Page):
  126. subpage_types = []
  127. .. attribute:: parent_page_types
  128. A list of page models which are allowed as parent page types. For example, a ``BlogPage`` may only allow itself to be created below the ``BlogIndex`` page:
  129. .. code-block:: python
  130. class BlogPage(Page):
  131. parent_page_types = ['mysite.BlogIndexPage']
  132. 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):
  133. .. code-block:: python
  134. class HiddenPage(Page):
  135. parent_page_types = []
  136. To allow for a page to be only created under the root page (e.g. for ``HomePage`` models) set the ``parent_page_type`` to ``['wagtailcore.Page']``.
  137. .. code-block:: python
  138. class HomePage(Page):
  139. parent_page_types = ['wagtailcore.Page']
  140. .. automethod:: can_exist_under
  141. .. automethod:: can_create_at
  142. .. automethod:: can_move_to
  143. .. automethod:: get_route_paths
  144. .. attribute:: password_required_template
  145. 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`
  146. .. attribute:: is_creatable
  147. Controls if this page can be created through the Wagtail administration. Defaults to ``True``, and is not inherited by subclasses. This is useful when using :ref:`multi-table inheritance <django:multi-table-inheritance>`, to stop the base model from being created as an actual page.
  148. .. attribute:: max_count
  149. Controls the maximum number of pages of this type that can be created through the Wagtail administration interface. This is useful when needing "allow at most 3 of these pages to exist", or for singleton pages.
  150. .. attribute:: max_count_per_parent
  151. Controls the maximum number of pages of this type that can be created under any one parent page.
  152. .. attribute:: exclude_fields_in_copy
  153. An array of field names that will not be included when a Page is copied.
  154. Useful when you have relations that do not use `ClusterableModel` or should not be copied.
  155. .. code-block:: python
  156. class BlogPage(Page):
  157. exclude_fields_in_copy = ['special_relation', 'custom_uuid']
  158. The following fields will always be excluded in a copy - `['id', 'path', 'depth', 'numchild', 'url_path', 'path']`.
  159. .. attribute:: base_form_class
  160. The form class used as a base for editing Pages of this type in the Wagtail page editor.
  161. This attribute can be set on a model to customise the Page editor form.
  162. Forms must be a subclass of :class:`~wagtail.admin.forms.WagtailAdminPageForm`.
  163. See :ref:`custom_edit_handler_forms` for more information.
  164. .. automethod:: with_content_json
  165. .. automethod:: save
  166. .. automethod:: create_alias
  167. .. automethod:: update_aliases
  168. .. autoattribute:: has_workflow
  169. .. automethod:: get_workflow
  170. .. autoattribute:: workflow_in_progress
  171. .. autoattribute:: current_workflow_state
  172. .. autoattribute:: current_workflow_task_state
  173. .. autoattribute:: current_workflow_task
  174. .. _site-model-ref:
  175. ``Site``
  176. ========
  177. 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.
  178. The :meth:`~wagtail.models.Site.find_for_request` function returns the Site object that will handle the given HTTP request.
  179. Database fields
  180. ~~~~~~~~~~~~~~~
  181. .. class:: Site
  182. .. attribute:: hostname
  183. (text)
  184. This is the hostname of the site, excluding the scheme, port and path.
  185. For example: ``www.mysite.com``
  186. .. note::
  187. If you're looking for how to get the root url of a site, use the :attr:`~Site.root_url` attribute.
  188. .. attribute:: port
  189. (number)
  190. This is the port number that the site responds on.
  191. .. attribute:: site_name
  192. (text - optional)
  193. A human-readable name for the site. This is not used by Wagtail itself, but is suitable for use on the site front-end, such as in ``<title>`` elements.
  194. For example: ``Rod's World of Birds``
  195. .. attribute:: root_page
  196. (foreign key to :class:`~wagtail.models.Page`)
  197. This is a link to the root page of the site. This page will be what appears at the ``/`` URL on the site and would usually be a homepage.
  198. .. attribute:: is_default_site
  199. (boolean)
  200. This is set to ``True`` if the site is the default. Only one site can be the default.
  201. The default site is used as a fallback in situations where a site with the required hostname/port couldn't be found.
  202. Methods and properties
  203. ~~~~~~~~~~~~~~~~~~~~~~
  204. .. class:: Site
  205. :noindex:
  206. .. automethod:: find_for_request
  207. .. autoattribute:: root_url
  208. This returns the URL of the site. It is calculated from the :attr:`~Site.hostname` and the :attr:`~Site.port` fields.
  209. The scheme part of the URL is calculated based on value of the :attr:`~Site.port` field:
  210. - 80 = ``http://``
  211. - 443 = ``https://``
  212. - Everything else will use the ``http://`` scheme and the port will be appended to the end of the hostname (eg. ``http://mysite.com:8000/``)
  213. .. automethod:: get_site_root_paths
  214. Locale
  215. ======
  216. The ``Locale`` model defines the set of languages and/or locales that can be used on a site.
  217. Each ``Locale`` record corresponds to a "language code" defined in the :ref:`wagtail_content_languages_setting` setting.
  218. Wagtail will initially set up one ``Locale`` to act as the default language for all existing content.
  219. 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``.
  220. If the primary language code is changed later, Wagtail will **not** automatically create a new ``Locale`` record or update an existing one.
  221. Before internationalisation is enabled, all pages use this primary ``Locale`` record.
  222. This is to satisfy the database constraints, and makes it easier to switch internationalisation on at a later date.
  223. Changing ``WAGTAIL_CONTENT_LANGUAGES``
  224. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  225. Languages can be added or removed from ``WAGTAIL_CONTENT_LANGUAGES`` over time.
  226. Before removing an option from ``WAGTAIL_CONTENT_LANGUAGES``, it's important that the ``Locale``
  227. record is updated to a use a different content language or is deleted.
  228. Any ``Locale`` instances that have invalid content languages are automatically filtered out from all
  229. database queries making them unable to be edited or viewed.
  230. Methods and properties
  231. ~~~~~~~~~~~~~~~~~~~~~~
  232. .. class:: Locale
  233. :noindex:
  234. .. autoattribute:: language_code
  235. .. automethod:: get_default
  236. .. automethod:: get_active
  237. .. automethod:: get_display_name
  238. Translatable Mixin
  239. ==================
  240. ``TranslatableMixin`` is an abstract model that can be added to any non-page Django model to make it translatable.
  241. Pages already include this mixin, so there is no need to add it.
  242. Methods and properties
  243. ~~~~~~~~~~~~~~~~~~~~~~
  244. The ``locale`` and ``translation_key`` fields have a unique key constraint to prevent the object being translated into a language more than once.
  245. .. class:: TranslatableMixin
  246. :noindex:
  247. .. attribute:: locale
  248. (Foreign Key to :class:`~wagtail.models.Locale`)
  249. For pages, this defaults to the locale of the parent page.
  250. .. attribute:: translation_key
  251. (uuid)
  252. A UUID that is randomly generated whenever a new model instance is created.
  253. This is shared with all translations of that instance so can be used for querying translations.
  254. .. automethod:: get_translations
  255. .. automethod:: get_translation
  256. .. automethod:: get_translation_or_none
  257. .. automethod:: has_translation
  258. .. automethod:: copy_for_translation
  259. .. automethod:: get_translation_model
  260. .. autoattribute:: localized
  261. .. _page-revision-model-ref:
  262. ``PageRevision``
  263. ================
  264. Every time a page is edited a new ``PageRevision`` 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.
  265. - Revisions can be created from any :class:`~wagtail.models.Page` object by calling its :meth:`~Page.save_revision` method
  266. - The content of the page is JSON-serialisable and stored in the :attr:`~PageRevision.content` field
  267. - You can retrieve a ``PageRevision`` as a :class:`~wagtail.models.Page` object by calling the :meth:`~PageRevision.as_page_object` method
  268. Database fields
  269. ~~~~~~~~~~~~~~~
  270. .. class:: PageRevision
  271. .. attribute:: page
  272. (foreign key to :class:`~wagtail.models.Page`)
  273. .. attribute:: submitted_for_moderation
  274. (boolean)
  275. ``True`` if this revision is in moderation
  276. .. attribute:: created_at
  277. (date/time)
  278. This is the time the revision was created
  279. .. attribute:: user
  280. (foreign key to user model)
  281. This links to the user that created the revision
  282. .. attribute:: content
  283. (dict)
  284. This field contains the JSON content for the page at the time the revision was created
  285. .. versionchanged:: 2.17
  286. The field has been renamed from ``content_json`` to ``content`` and it now uses :class:`~django.db.models.JSONField` instead of
  287. :class:`~django.db.models.TextField`.
  288. Managers
  289. ~~~~~~~~
  290. .. class:: PageRevision
  291. :noindex:
  292. .. attribute:: objects
  293. This manager is used to retrieve all of the ``PageRevision`` objects in the database
  294. Example:
  295. .. code-block:: python
  296. PageRevision.objects.all()
  297. .. attribute:: submitted_revisions
  298. This manager is used to retrieve all of the ``PageRevision`` objects that are awaiting moderator approval
  299. Example:
  300. .. code-block:: python
  301. PageRevision.submitted_revisions.all()
  302. Methods and properties
  303. ~~~~~~~~~~~~~~~~~~~~~~
  304. .. class:: PageRevision
  305. :noindex:
  306. .. automethod:: as_page_object
  307. This method retrieves this revision as an instance of its :class:`~wagtail.models.Page` subclass.
  308. .. automethod:: approve_moderation
  309. Calling this on a revision that's in moderation will mark it as approved and publish it
  310. .. automethod:: reject_moderation
  311. Calling this on a revision that's in moderation will mark it as rejected
  312. .. automethod:: is_latest_revision
  313. Returns ``True`` if this revision is its page's latest revision
  314. .. automethod:: publish
  315. Calling this will copy the content of this revision into the live page object. If the page is in draft, it will be published.
  316. ``GroupPagePermission``
  317. =======================
  318. Database fields
  319. ~~~~~~~~~~~~~~~
  320. .. class:: GroupPagePermission
  321. .. attribute:: group
  322. (foreign key to ``django.contrib.auth.models.Group``)
  323. .. attribute:: page
  324. (foreign key to :class:`~wagtail.models.Page`)
  325. .. attribute:: permission_type
  326. (choice list)
  327. ``PageViewRestriction``
  328. =======================
  329. Database fields
  330. ~~~~~~~~~~~~~~~
  331. .. class:: PageViewRestriction
  332. .. attribute:: page
  333. (foreign key to :class:`~wagtail.models.Page`)
  334. .. attribute:: password
  335. (text)
  336. ``Orderable`` (abstract)
  337. ========================
  338. Database fields
  339. ~~~~~~~~~~~~~~~
  340. .. class:: Orderable
  341. .. attribute:: sort_order
  342. (number)
  343. ``Workflow``
  344. ============
  345. Workflows represent sequences of tasks which much be approved for an action to be performed on a page - typically publication.
  346. Database fields
  347. ~~~~~~~~~~~~~~~
  348. .. class:: Workflow
  349. .. attribute:: name
  350. (text)
  351. Human-readable name of the workflow.
  352. .. attribute:: active
  353. (boolean)
  354. Whether or not the workflow is active: active workflows can be added to pages, and started. Inactive workflows cannot.
  355. Methods and properties
  356. ~~~~~~~~~~~~~~~~~~~~~~
  357. .. class:: Workflow
  358. :noindex:
  359. .. automethod:: start
  360. .. autoattribute:: tasks
  361. .. automethod:: deactivate
  362. .. automethod:: all_pages
  363. ``WorkflowState``
  364. =================
  365. Workflow states represent the status of a started workflow on a page.
  366. Database fields
  367. ~~~~~~~~~~~~~~~
  368. .. class:: WorkflowState
  369. .. attribute:: page
  370. (foreign key to ``Page``)
  371. The page on which the workflow has been started
  372. .. attribute:: workflow
  373. (foreign key to ``Workflow``)
  374. The workflow whose state the ``WorkflowState`` represents
  375. .. attribute:: status
  376. (text)
  377. The current status of the workflow (options are ``WorkflowState.STATUS_CHOICES``)
  378. .. attribute:: created_at
  379. (date/time)
  380. When this instance of ``WorkflowState`` was created - when the workflow was started
  381. .. attribute:: requested_by
  382. (foreign key to user model)
  383. The user who started this workflow
  384. .. attribute:: current_task_state
  385. (foreign key to ``TaskState``)
  386. The ``TaskState`` model for the task the workflow is currently at: either completing (if in progress) or the final task state (if finished)
  387. Methods and properties
  388. ~~~~~~~~~~~~~~~~~~~~~~
  389. .. class:: WorkflowState
  390. :noindex:
  391. .. attribute:: STATUS_CHOICES
  392. A tuple of the possible options for the ``status`` field, and their verbose names. Options are ``STATUS_IN_PROGRESS``, ``STATUS_APPROVED``,
  393. ``STATUS_CANCELLED`` and ``STATUS_NEEDS_CHANGES``.
  394. .. automethod:: update
  395. .. automethod:: get_next_task
  396. .. automethod:: cancel
  397. .. automethod:: finish
  398. .. automethod:: resume
  399. .. automethod:: copy_approved_task_states_to_revision
  400. .. automethod:: all_tasks_with_status
  401. .. automethod:: revisions
  402. ``Task``
  403. ========
  404. Tasks represent stages in a workflow which must be approved for the workflow to complete successfully.
  405. Database fields
  406. ~~~~~~~~~~~~~~~
  407. .. class:: Task
  408. .. attribute:: name
  409. (text)
  410. Human-readable name of the task.
  411. .. attribute:: active
  412. (boolean)
  413. Whether or not the task is active: active workflows can be added to workflows, and started. Inactive workflows cannot, and are skipped when in
  414. an existing workflow.
  415. .. attribute:: content_type
  416. (foreign key to ``django.contrib.contenttypes.models.ContentType``)
  417. A foreign key to the :class:`~django.contrib.contenttypes.models.ContentType` object that represents the specific model of this task.
  418. Methods and properties
  419. ~~~~~~~~~~~~~~~~~~~~~~
  420. .. class:: Task
  421. :noindex:
  422. .. autoattribute:: workflows
  423. .. autoattribute:: active_workflows
  424. .. attribute:: task_state_class
  425. The specific task state class to generate to store state information for this task. If not specified, this will be ``TaskState``.
  426. .. automethod:: get_verbose_name
  427. .. autoattribute:: specific
  428. .. automethod:: start
  429. .. automethod:: on_action
  430. .. automethod:: user_can_access_editor
  431. .. automethod:: user_can_lock
  432. .. automethod:: user_can_unlock
  433. .. automethod:: page_locked_for_user
  434. .. automethod:: get_actions
  435. .. automethod:: get_task_states_user_can_moderate
  436. .. automethod:: deactivate
  437. .. automethod:: get_form_for_action
  438. .. automethod:: get_template_for_action
  439. .. automethod:: get_description
  440. ``TaskState``
  441. =============
  442. Task states store state information about the progress of a task on a particular page revision.
  443. Database fields
  444. ~~~~~~~~~~~~~~~
  445. .. class:: TaskState
  446. .. attribute:: workflow_state
  447. (foreign key to ``WorkflowState``)
  448. The workflow state which started this task state.
  449. .. attribute:: page_revision
  450. (foreign key to ``PageRevision``)
  451. The page revision this task state was created on.
  452. .. attribute:: task
  453. (foreign key to ``Task``)
  454. The task that this task state is storing state information for.
  455. .. attribute:: status
  456. (text)
  457. The completion status of the task on this revision. Options are available in ``TaskState.STATUS_CHOICES``)
  458. .. attribute:: content_type
  459. (foreign key to ``django.contrib.contenttypes.models.ContentType``)
  460. A foreign key to the :class:`~django.contrib.contenttypes.models.ContentType` object that represents the specific model of this task.
  461. .. attribute:: started_at
  462. (date/time)
  463. When this task state was created.
  464. .. attribute:: finished_at
  465. (date/time)
  466. When this task state was cancelled, rejected, or approved.
  467. .. attribute:: finished_by
  468. (foreign key to user model)
  469. The user who completed (cancelled, rejected, approved) the task.
  470. .. attribute:: comment
  471. (text)
  472. A text comment, typically added by a user when the task is completed.
  473. Methods and properties
  474. ~~~~~~~~~~~~~~~~~~~~~~
  475. .. class:: TaskState
  476. :noindex:
  477. .. attribute:: STATUS_CHOICES
  478. A tuple of the possible options for the ``status`` field, and their verbose names. Options are ``STATUS_IN_PROGRESS``, ``STATUS_APPROVED``,
  479. ``STATUS_CANCELLED``, ``STATUS_REJECTED`` and ``STATUS_SKIPPED``.
  480. .. attribute:: exclude_fields_in_copy
  481. A list of fields not to copy when the ``TaskState.copy()`` method is called.
  482. .. autoattribute:: specific
  483. .. automethod:: approve
  484. .. automethod:: reject
  485. .. autoattribute:: task_type_started_at
  486. .. automethod:: cancel
  487. .. automethod:: copy
  488. .. automethod:: get_comment
  489. ``WorkflowTask``
  490. ================
  491. Represents the ordering of a task in a specific workflow.
  492. Database fields
  493. ~~~~~~~~~~~~~~~
  494. .. class:: WorkflowTask
  495. .. attribute:: workflow
  496. (foreign key to ``Workflow``)
  497. .. attribute:: task
  498. (foreign key to ``Task``)
  499. .. attribute:: sort_order
  500. (number)
  501. The ordering of the task in the workflow.
  502. ``WorkflowPage``
  503. ================
  504. Represents the assignment of a workflow to a page and its descendants.
  505. Database fields
  506. ~~~~~~~~~~~~~~~
  507. .. class:: WorkflowPage
  508. .. attribute:: workflow
  509. (foreign key to ``Workflow``)
  510. .. attribute:: page
  511. (foreign key to ``Page``)
  512. ``BaseLogEntry``
  513. ================
  514. An abstract base class that represents a record of an action performed on an object.
  515. Database fields
  516. ~~~~~~~~~~~~~~~
  517. .. class:: BaseLogEntry
  518. .. attribute:: content_type
  519. (foreign key to ``django.contrib.contenttypes.models.ContentType``)
  520. A foreign key to the :class:`~django.contrib.contenttypes.models.ContentType` object that represents the specific model of this model.
  521. .. attribute:: label
  522. (text)
  523. The object title at the time of the entry creation
  524. Note: Wagtail will attempt to use ``get_admin_display_title`` or the string representation of the object passed to :meth:`~LogEntryManger.log_action`
  525. .. attribute:: user
  526. (foreign key to user model)
  527. A foreign key to the user that triggered the action.
  528. .. attribute:: data
  529. (dict)
  530. The JSON representation of any additional details for each action.
  531. e.g. source page id and title when copying from a page. Or workflow id/name and next step id/name on a workflow transition
  532. .. versionchanged:: 2.17
  533. The field has been renamed from ``data_json`` to ``data`` and it now uses :class:`~django.db.models.JSONField` instead of
  534. :class:`~django.db.models.TextField`.
  535. .. attribute:: timestamp
  536. (date/time)
  537. The date/time when the entry was created.
  538. .. attribute:: content_changed
  539. (boolean)
  540. A boolean that can set to ``True`` when the content has changed.
  541. .. attribute:: deleted
  542. (boolean)
  543. A boolean that can set to ``True`` when the object is deleted. Used to filter entries in the Site History report.
  544. Methods and properties
  545. ~~~~~~~~~~~~~~~~~~~~~~
  546. .. class:: BaseLogEntry
  547. :noindex:
  548. .. autoattribute:: user_display_name
  549. .. autoattribute:: comment
  550. .. autoattribute:: object_verbose_name
  551. .. automethod:: object_id
  552. ``PageLogEntry``
  553. ================
  554. Represents a record of an action performed on an :class:`Page`, subclasses :class:`BaseLogEntry`.
  555. Database fields
  556. ~~~~~~~~~~~~~~~
  557. .. class:: PageLogEntry
  558. .. attribute:: page
  559. (foreign key to :class:`Page`)
  560. A foreign key to the page the action is performed on.
  561. .. attribute:: revision
  562. (foreign key to :class:`PageRevision`)
  563. A foreign key to the current page revision.
  564. ``Comment``
  565. ===========
  566. Represents a comment on a page.
  567. Database fields
  568. ~~~~~~~~~~~~~~~
  569. .. class:: Comment
  570. .. attribute:: page
  571. (parental key to :class:`Page`)
  572. A parental key to the page the comment has been added to.
  573. .. attribute:: user
  574. (foreign key to user model)
  575. A foreign key to the user who added this comment.
  576. .. attribute:: text
  577. (text)
  578. The text content of the comment.
  579. .. attribute:: contentpath
  580. (text)
  581. The path to the field or streamfield block the comment is attached to,
  582. in the form ``field`` or ``field.streamfield_block_id``.
  583. .. attribute:: position
  584. (text)
  585. An identifier for the position of the comment within its field. The format
  586. used is determined by the field.
  587. .. attribute:: created_at
  588. (date/time)
  589. The date/time when the comment was created.
  590. .. attribute:: updated_at
  591. (date/time)
  592. The date/time when the comment was updated.
  593. .. attribute:: revision_created
  594. (foreign key to :class:`PageRevision`)
  595. A foreign key to the revision on which the comment was created.
  596. .. attribute:: resolved_at
  597. (date/time)
  598. The date/time when the comment was resolved, if any.
  599. .. attribute:: resolved_by
  600. (foreign key to user model)
  601. A foreign key to the user who resolved this comment, if any.
  602. ``CommentReply``
  603. ================
  604. Represents a reply to a comment thread.
  605. Database fields
  606. ~~~~~~~~~~~~~~~
  607. .. class:: CommentReply
  608. .. attribute:: comment
  609. (parental key to :class:`Comment`)
  610. A parental key to the comment that started the thread.
  611. .. attribute:: user
  612. (foreign key to user model)
  613. A foreign key to the user who added this comment.
  614. .. attribute:: text
  615. (text)
  616. The text content of the comment.
  617. .. attribute:: created_at
  618. (date/time)
  619. The date/time when the comment was created.
  620. .. attribute:: updated_at
  621. (date/time)
  622. The date/time when the comment was updated.
  623. ``PageSubscription``
  624. ====================
  625. Represents a user's subscription to email notifications about page events.
  626. Currently only used for comment notifications.
  627. Database fields
  628. ~~~~~~~~~~~~~~~
  629. .. class:: PageSubscription
  630. .. attribute:: page
  631. (parental key to :class:`Page`)
  632. .. attribute:: user
  633. (foreign key to user model)
  634. .. attribute:: comment_notifications
  635. (boolean)
  636. Whether the user should receive comment notifications for all comments,
  637. or just comments in threads they participate in.