mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-27 12:04:02 +03:00
Added get_renderers method to ResponseMixin
This commit is contained in:
parent
c1fe5da85f
commit
dd680d7a0a
|
@ -222,6 +222,13 @@ class ResponseMixin(object):
|
||||||
Should be a tuple/list of classes as described in the :mod:`renderers` module.
|
Should be a tuple/list of classes as described in the :mod:`renderers` module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def get_renderers(self):
|
||||||
|
"""
|
||||||
|
Return an iterable of available renderers. Override if you want to change
|
||||||
|
this list at runtime, say depending on what settings you have enabled.
|
||||||
|
"""
|
||||||
|
return self.renderers
|
||||||
|
|
||||||
# TODO: wrap this behavior around dispatch(), ensuring it works
|
# TODO: wrap this behavior around dispatch(), ensuring it works
|
||||||
# out of the box with existing Django classes that use render_to_response.
|
# out of the box with existing Django classes that use render_to_response.
|
||||||
def render(self, response):
|
def render(self, response):
|
||||||
|
@ -283,7 +290,7 @@ class ResponseMixin(object):
|
||||||
# attempting more specific media types first
|
# attempting more specific media types first
|
||||||
# NB. The inner loop here isn't as bad as it first looks :)
|
# NB. The inner loop here isn't as bad as it first looks :)
|
||||||
# Worst case is we're looping over len(accept_list) * len(self.renderers)
|
# Worst case is we're looping over len(accept_list) * len(self.renderers)
|
||||||
renderers = [renderer_cls(self) for renderer_cls in self.renderers]
|
renderers = [renderer_cls(self) for renderer_cls in self.get_renderers()]
|
||||||
|
|
||||||
for accepted_media_type_lst in order_by_precedence(accept_list):
|
for accepted_media_type_lst in order_by_precedence(accept_list):
|
||||||
for renderer in renderers:
|
for renderer in renderers:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user