浏览代码

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 年之前
父节点
当前提交
9ae4ab6084
共有 1 个文件被更改,包括 7 次插入0 次删除
  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