From 7ee1bbecc652ed3237182399bd644c1d42dff2db Mon Sep 17 00:00:00 2001 From: Jens Alm Date: Sat, 2 Jul 2011 18:38:55 +0200 Subject: [PATCH] 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 --- djangorestframework/parsers.py | 6 ++++++ djangorestframework/views.py | 12 ++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/djangorestframework/parsers.py b/djangorestframework/parsers.py index 5f19c521b..cfe8ec9ed 100644 --- a/djangorestframework/parsers.py +++ b/djangorestframework/parsers.py @@ -167,3 +167,9 @@ class MultiPartParser(BaseParser): {'detail': 'multipart parse error - %s' % unicode(exc)}) return django_parser.parse() +DEFAULT_PARSERS = ( JSONParser, + FormParser, + MultiPartParser ) + +if YAMLParser: + DEFAULT_PARSERS += (YAMLParser,) \ No newline at end of file diff --git a/djangorestframework/views.py b/djangorestframework/views.py index 757d89db4..aedc7427b 100644 --- a/djangorestframework/views.py +++ b/djangorestframework/views.py @@ -40,20 +40,12 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView): """ List of renderers the resource can serialize the response with, ordered by preference. """ - renderers = ( renderers.JSONRenderer, - renderers.DocumentingHTMLRenderer, - renderers.DocumentingXHTMLRenderer, - renderers.DocumentingPlainTextRenderer, - renderers.XMLRenderer, - renderers.YAMLRenderer ) + renderers = renderers.DEFAULT_RENDERERS """ List of parsers the resource can parse the request with. """ - parsers = ( parsers.JSONParser, - parsers.FormParser, - parsers.MultiPartParser ) - + parsers = parsers.DEFAULT_PARSERS """ List of all authenticating methods to attempt. """