model_reference.rst 29 KB

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