Python rest_framework.settings.api_settings.DEFAULT_RENDERER_CLASSES Examples
The following are 3
code examples of rest_framework.settings.api_settings.DEFAULT_RENDERER_CLASSES().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
rest_framework.settings.api_settings
, or try the search function
.
Example #1
Source File: mixins.py From django-spillway with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #2
Source File: routers.py From Dailyfresh-B2C with Apache License 2.0 | 5 votes |
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)
Example #3
Source File: views.py From Dailyfresh-B2C with Apache License 2.0 | 5 votes |
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]