当前位置: 首页>>代码示例>>Python>>正文


Python models.route方法代码示例

本文整理汇总了Python中wagtail.contrib.routable_page.models.route方法的典型用法代码示例。如果您正苦于以下问题:Python models.route方法的具体用法?Python models.route怎么用?Python models.route使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wagtail.contrib.routable_page.models的用法示例。


在下文中一共展示了models.route方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: route

# 需要导入模块: from wagtail.contrib.routable_page import models [as 别名]
# 或者: from wagtail.contrib.routable_page.models import route [as 别名]
def route(self, request, path_components):
        """
        Overrides RoutablePageMixin.route() to allow articles to have
        publish date components in URLs."""

        if len(path_components) >= 4:

            # Attempt to route to an article using date/slug components
            # NOTE: The page must have been published in order for
            # `first_published_at` to be set
            try:
                year = path_components[0]  # year
                month = path_components[1]  # month
                day = path_components[2]  # day
                slug = path_components[3]  # slug
                publish_date = date(int(year), int(month), int(day))
            except ValueError:
                # Date components invalid
                raise Http404

            try:
                # Find an article matching the above date and slug
                article = ArticlePage.objects.child_of(self).get(
                    publish_date=publish_date, slug=slug)
            except ArticlePage.DoesNotExist:
                raise Http404

            # Delegate further routing to the arcicle, excluding the
            # date and slug components used above
            return article.route(request, path_components[4:])

        return super().route(request, path_components) 
开发者ID:rkhleics,项目名称:wagtailmenus,代码行数:34,代码来源:pages.py

示例2: _getExtraContext

# 需要导入模块: from wagtail.contrib.routable_page import models [as 别名]
# 或者: from wagtail.contrib.routable_page.models import route [as 别名]
def _getExtraContext(self, route):
        return {} 
开发者ID:linuxsoftware,项目名称:ls.joyous,代码行数:4,代码来源:calendar.py


注:本文中的wagtail.contrib.routable_page.models.route方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。