Set default renderers for views when yaml is not installed

Will use the renderer.DEFAULT_RENDERERS dict for determining available renderers in views.View to avoid a nonexistent renderer when yaml is not installed. Duplicates the behavior in parsers.DEFAULT_PARSERS
This commit is contained in:
Jens Alm 2011-07-02 18:38:55 +02:00
parent 83b47c4b76
commit 7ee1bbecc6
2 changed files with 8 additions and 10 deletions

View File

@ -167,3 +167,9 @@ class MultiPartParser(BaseParser):
{'detail': 'multipart parse error - %s' % unicode(exc)}) {'detail': 'multipart parse error - %s' % unicode(exc)})
return django_parser.parse() return django_parser.parse()
DEFAULT_PARSERS = ( JSONParser,
FormParser,
MultiPartParser )
if YAMLParser:
DEFAULT_PARSERS += (YAMLParser,)

View File

@ -40,20 +40,12 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
""" """
List of renderers the resource can serialize the response with, ordered by preference. List of renderers the resource can serialize the response with, ordered by preference.
""" """
renderers = ( renderers.JSONRenderer, renderers = renderers.DEFAULT_RENDERERS
renderers.DocumentingHTMLRenderer,
renderers.DocumentingXHTMLRenderer,
renderers.DocumentingPlainTextRenderer,
renderers.XMLRenderer,
renderers.YAMLRenderer )
""" """
List of parsers the resource can parse the request with. List of parsers the resource can parse the request with.
""" """
parsers = ( parsers.JSONParser, parsers = parsers.DEFAULT_PARSERS
parsers.FormParser,
parsers.MultiPartParser )
""" """
List of all authenticating methods to attempt. List of all authenticating methods to attempt.
""" """