Document how to limit a page parent to root

Closes #2768

Issue #2768 was created because a way how to limit a page to be only
available under the root page was unknown.

The implementation has allowed this for a while now, but the issue was
not closed (presumably due to missing documentation).

The documentation of the `parent_page_types` filed now includes this
"special" case.
pull/7501/head
Tibor Leupold 2021-09-03 16:21:33 -07:00 zatwierdzone przez Matt Westcott
rodzic 45b7788c6d
commit 9ae4ab6084
1 zmienionych plików z 7 dodań i 0 usunięć

Wyświetl plik

@ -256,6 +256,13 @@ In addition to the model fields provided, ``Page`` has many properties and metho
class HiddenPage(Page):
parent_page_types = []
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']``.
.. code-block:: python
class HomePage(Page):
parent_page_types = ['wagtailcore.Page']
.. automethod:: can_exist_under
.. automethod:: can_create_at