Closed
Description
I get a crash in this code snippet, which works in version 3.1.0:
from rest_framework import permissions, status
from rest_framework.generics import GenericAPIView
from rest_framework.response import Response
from my_serializers import MySerializer
class MyAPIView(GenericAPIView):
permission_classes = (permissions.AllowAny,)
serializer_class = MySerializer
def get(self, request, **kwargs):
data = request.query_params.copy()
serializer = self.get_serializer(data=data)
if serializer.is_valid():
return Response(status=status.HTTP_204_NO_CONTENT)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
The partial stack trace is
File "/path_to_my_project/views/my_view.py", line 14, in get
serializer = self.get_serializer(data=data)
File "/path_to_my_virtualenv/lib/python3.5/site-packages/rest_framework/generics.py", line 110, in get_serializer
return serializer_class(*args, **kwargs)
File "/path_to_my_virtualenv/lib/python3.5/site-packages/rest_framework_json_api/serializers.py", line 118, in __init__
super(IncludedResourcesValidationMixin, self).__init__(*args, **kwargs)
File "/path_to_my_virtualenv/lib/python3.5/site-packages/rest_framework_json_api/serializers.py", line 67, in __init__
get_resource_type_from_serializer(self)
File "/path_to_my_virtualenv/lib/python3.5/site-packages/rest_framework_json_api/utils.py", line 240, in get_resource_type_from_serializer
raise AttributeError()
AttributeError
I run into the same error on a POST request in a different area.
Looking at the changelog and commits between 3.1.0 and 3.2.0 and suspect this commit could be related:
ff0f93a
Is this an error in the library?
Am I doing something wrong, which used to be masked before?