當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。