Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mbande opened this issue Aug 27, 2016 · 1 comment
Open

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

mbande opened this issue Aug 27, 2016 · 1 comment

Comments

@mbande
Copy link

mbande commented Aug 27, 2016

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

@weasteam
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants