本文整理匯總了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
示例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)
示例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]