diff options
| author | Tom Christie | 2013-04-16 14:32:46 +0100 | 
|---|---|---|
| committer | Tom Christie | 2013-04-16 14:32:46 +0100 | 
| commit | 23289b023db230f73e4a5bfae24a56c79e3fcd4b (patch) | |
| tree | d9df404c0a8791eb3db4ae25ec3fbd42d77e7c02 /rest_framework | |
| parent | 0c1b8b4f767bddb30e0df2f5411cc4798d403de7 (diff) | |
| download | django-rest-framework-23289b023db230f73e4a5bfae24a56c79e3fcd4b.tar.bz2 | |
Explicit error if dev does not return a response from the view
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/views.py | 8 | 
1 files changed, 7 insertions, 1 deletions
diff --git a/rest_framework/views.py b/rest_framework/views.py index 81cbdcbb..7c97607b 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -3,7 +3,7 @@ Provides an APIView class that is used as the base of all class-based views.  """  from __future__ import unicode_literals  from django.core.exceptions import PermissionDenied -from django.http import Http404 +from django.http import Http404, HttpResponse  from django.utils.html import escape  from django.utils.safestring import mark_safe  from django.views.decorators.csrf import csrf_exempt @@ -327,6 +327,12 @@ class APIView(View):          """          Returns the final response object.          """ +        # Make the error obvious if a proper response is not returned +        assert isinstance(response, HttpResponse), ( +            'Expected a `Response` to be returned from the view, ' +            'but received a `%s`' % type(response) +        ) +          if isinstance(response, Response):              if not getattr(request, 'accepted_renderer', None):                  neg = self.perform_content_negotiation(request, force=True)  | 
