django-rest-framework-bulk icon indicating copy to clipboard operation
django-rest-framework-bulk copied to clipboard

AttributeError: 'NoneType' object has no attribute 'request'

Open mbande opened this issue 9 years ago • 1 comments

I've added BulkSerializerMixin to a view set (and set list_serializer_class to BulkListSerializer), trying to PATCH a single object (which should not touch bulk operations at all), raises this error: AttributeError: 'NoneType' object has no attribute 'request' may be related to #39 using Django 1.10 with 3.4.6

mbande avatar Aug 27 '16 13:08 mbande

I was doing POST and get the same error.

  File "/usr/local/lib/python3.5/site-packages/rest_framework_bulk/drf3/serializers.py", line 19, in to_internal_value
    request_method = getattr(getattr(self.context.get('view'), 'request'), 'method', '')
AttributeError: 'NoneType' object has no attribute 'request'

It looks like view is not pass to context.

I fixed this one via updating get_serializer_context method:

    def get_serializer_context(self):
        data = {}
        data["view"] = self
        return data

weasteam avatar Sep 29 '17 05:09 weasteam