mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Merge branch 'master' of github.com:tomchristie/django-rest-framework
This commit is contained in:
commit
b7e47e3d67
|
@ -10,6 +10,8 @@ from django.template.response import SimpleTemplateResponse
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.six.moves.http_client import responses
|
from django.utils.six.moves.http_client import responses
|
||||||
|
|
||||||
|
from rest_framework.serializers import Serializer
|
||||||
|
|
||||||
|
|
||||||
class Response(SimpleTemplateResponse):
|
class Response(SimpleTemplateResponse):
|
||||||
"""
|
"""
|
||||||
|
@ -28,6 +30,15 @@ class Response(SimpleTemplateResponse):
|
||||||
For example being set automatically by the `APIView`.
|
For example being set automatically by the `APIView`.
|
||||||
"""
|
"""
|
||||||
super(Response, self).__init__(None, status=status)
|
super(Response, self).__init__(None, status=status)
|
||||||
|
|
||||||
|
if isinstance(data, Serializer):
|
||||||
|
msg = (
|
||||||
|
'You passed a Serializer instance as data, but '
|
||||||
|
'probably meant to pass serialized `.data` or '
|
||||||
|
'`.error`. representation.'
|
||||||
|
)
|
||||||
|
raise AssertionError(msg)
|
||||||
|
|
||||||
self.data = data
|
self.data = data
|
||||||
self.template_name = template_name
|
self.template_name = template_name
|
||||||
self.exception = exception
|
self.exception = exception
|
||||||
|
|
Loading…
Reference in New Issue
Block a user