model_reference.rst 26 KB

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