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

Django rest framework: User not found in request #78

Closed
somangshu opened this issue Apr 14, 2020 · 1 comment
Closed

Django rest framework: User not found in request #78

somangshu opened this issue Apr 14, 2020 · 1 comment

Comments

@somangshu
Copy link

Hi,
I am using using Django Rest Rramework.

I got the package working with all setup in place, The API to save information is called and executed successfully. The only problem right now is that the user information is not saved. My findings say that this is because I am using DRF. The way DRF injects a user into the request is may be different from how the traditional Django does. And hence the request.user in the view of the package in not found.

Right now i am thinking to make a clone of the repo and make changes directly in order to debug and find the exact issue/solution.

Kindly let me know what would be the right way. Or is there is a existing solution to this already.

Thanks

@somangshu
Copy link
Author

The given package safwanrahman/django-webpush is not compatible with Django rest framework, As the package core classes in view use the post and http methods from the django core classes, Which cannot find the user if you have changed the authentication middleware while using DRF.

The solution to that is to import the package folder and make changes in the view such that the view function being called is inherited from the DRF core classes and hence fourth able to find the logged in user in the request object. I am still trying to understand if somehow only that class can be extended and changed. But for now this solution works for me.

Thanks.

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

1 participant