Przeglądaj źródła

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.
Tibor Leupold 3 lat temu
rodzic
commit
9ae4ab6084
1 zmienionych plików z 7 dodań i 0 usunięć
  1. 7 0
      docs/reference/pages/model_reference.rst

+ 7 - 0
docs/reference/pages/model_reference.rst

@@ -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