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


Python api_settings.DEFAULT_RENDERER_CLASSES屬性代碼示例

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


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

示例1: handle_exception

# 需要導入模塊: from rest_framework.settings import api_settings [as 別名]
# 或者: from rest_framework.settings.api_settings import DEFAULT_RENDERER_CLASSES [as 別名]
def handle_exception(self, exc):
        response = super(ResponseExceptionMixin, self).handle_exception(exc)
        renderers = tuple(api_settings.DEFAULT_RENDERER_CLASSES)
        accepted = getattr(self.request, 'accepted_renderer', None)
        if (response.exception and accepted
                and not isinstance(accepted, renderers)):
            conneg = self.get_content_negotiator()
            try:
                render_cls, mtype = conneg.select_renderer(
                    self.request, renderers, self.format_kwarg)
            except exceptions.NotAcceptable:
                render_cls = TemplateHTMLRenderer
                mtype = render_cls.media_type
            self.request.accepted_renderer = render_cls()
            self.request.accepted_media_type = mtype
        return response 
開發者ID:bkg,項目名稱:django-spillway,代碼行數:18,代碼來源:mixins.py

示例2: __init__

# 需要導入模塊: from rest_framework.settings import api_settings [as 別名]
# 或者: from rest_framework.settings.api_settings import DEFAULT_RENDERER_CLASSES [as 別名]
def __init__(self, *args, **kwargs):
        if 'root_renderers' in kwargs:
            self.root_renderers = kwargs.pop('root_renderers')
        else:
            self.root_renderers = list(api_settings.DEFAULT_RENDERER_CLASSES)
        super(DefaultRouter, self).__init__(*args, **kwargs) 
開發者ID:BeanWei,項目名稱:Dailyfresh-B2C,代碼行數:8,代碼來源:routers.py

示例3: __init__

# 需要導入模塊: from rest_framework.settings import api_settings [as 別名]
# 或者: from rest_framework.settings.api_settings import DEFAULT_RENDERER_CLASSES [as 別名]
def __init__(self, *args, **kwargs):
        super(SchemaView, self).__init__(*args, **kwargs)
        if self.renderer_classes is None:
            if renderers.BrowsableAPIRenderer in api_settings.DEFAULT_RENDERER_CLASSES:
                self.renderer_classes = [
                    renderers.CoreJSONRenderer,
                    renderers.BrowsableAPIRenderer,
                ]
            else:
                self.renderer_classes = [renderers.CoreJSONRenderer] 
開發者ID:BeanWei,項目名稱:Dailyfresh-B2C,代碼行數:12,代碼來源:views.py


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