當前位置: 首頁>>代碼示例>>Python>>正文


Python Page._get_children_path_interval方法代碼示例

本文整理匯總了Python中wagtail.core.models.Page._get_children_path_interval方法的典型用法代碼示例。如果您正苦於以下問題:Python Page._get_children_path_interval方法的具體用法?Python Page._get_children_path_interval怎麽用?Python Page._get_children_path_interval使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wagtail.core.models.Page的用法示例。


在下文中一共展示了Page._get_children_path_interval方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_page

# 需要導入模塊: from wagtail.core.models import Page [as 別名]
# 或者: from wagtail.core.models.Page import _get_children_path_interval [as 別名]
    def get_page(self):
        (content_type_app_name, content_type_model_name,
         parent_page_id) = self.args
        try:
            content_type = ContentType.objects.get_by_natural_key(
                content_type_app_name, content_type_model_name)
        except ContentType.DoesNotExist:
            raise Http404

        page = content_type.model_class()()
        parent_page = get_object_or_404(Page, id=parent_page_id).specific
        # We need to populate treebeard's path / depth fields in order to
        # pass validation. We can't make these 100% consistent with the rest
        # of the tree without making actual database changes (such as
        # incrementing the parent's numchild field), but by calling treebeard's
        # internal _get_path method, we can set a 'realistic' value that will
        # hopefully enable tree traversal operations
        # to at least partially work.
        page.depth = parent_page.depth + 1
        # Puts the page at the maximum possible path
        # for a child of `parent_page`.
        page.path = Page._get_children_path_interval(parent_page.path)[1]
        return page
開發者ID:hellomrjack,項目名稱:wagtail,代碼行數:25,代碼來源:pages.py


注:本文中的wagtail.core.models.Page._get_children_path_interval方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。