mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Explicit error if dev does not return a response from the view
This commit is contained in:
parent
0c1b8b4f76
commit
23289b023d
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user