本文整理汇总了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]