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


Python urlpatterns.format_suffix_patterns方法代码示例

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


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

示例1: get_urls

# 需要导入模块: from rest_framework import urlpatterns [as 别名]
# 或者: from rest_framework.urlpatterns import format_suffix_patterns [as 别名]
def get_urls(self):
        """
        Generate the list of URL patterns, including a default root view
        for the API, and appending `.json` style format suffixes.
        """
        urls = super(DefaultRouter, self).get_urls()

        if self.include_root_view:
            view = self.get_api_root_view(api_urls=urls)
            root_url = url(r'^$', view, name=self.root_view_name)
            urls.append(root_url)

        if self.include_format_suffixes:
            urls = format_suffix_patterns(urls)

        return urls 
开发者ID:BeanWei,项目名称:Dailyfresh-B2C,代码行数:18,代码来源:routers.py

示例2: get_urls

# 需要导入模块: from rest_framework import urlpatterns [as 别名]
# 或者: from rest_framework.urlpatterns import format_suffix_patterns [as 别名]
def get_urls(self):
        ret = []

        if self.include_root_view:
            root_url = url(r'^$', self.get_api_root_view(),
                           name=self.root_view_name)
            ret.append(root_url)
        for prefix, viewset, basename in self.registry:
            lookup = self.get_lookup_regex(viewset)
            lookup_list = self.get_lookup_regexes(viewset)
            if lookup_list:
                # lookup = lookups[0]
                lookup_list = [u'/'.join(k) for k in lookup_list]
            else:
                lookup_list = [u'']
            routes = self.get_routes(viewset)
            for route in routes:
                mapping = self.get_method_map(viewset, route.mapping)
                if not mapping:
                    continue
                for lookups in lookup_list:
                    regex = route.url.format(
                        prefix=prefix,
                        lookup=lookup,
                        lookups=lookups,
                        trailing_slash=self.trailing_slash,
                        extra=self.get_extra_lookup_regexes(route)
                    )
                    view = viewset.as_view(mapping, **route.initkwargs)
                    name = route.name.format(basename=basename)
                    ret.append(url(regex, view, name=name))
        if self.include_format_suffixes:
            ret = format_suffix_patterns(ret, allowed=['[a-z0-9]+'])
        return ret 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:36,代码来源:urls.py


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