Hi, Does this happen during real requests or in test-cases ? For real HTTP request custom middleware might be the answer, please check https://github.com/GetBlimp/django-rest-framework-jwt/issues/45 Such middleware should override "request.user" using REST_FRAMEWORK. DEFAULT_AUTHENTICATION_CLASSES and be put in config file before other middleware which user request.user.
Test-cases might require "force_login()" instead of "force_authenticate()" for request.user to work in middleware. On Sat, Nov 30, 2019 at 9:06 PM Yery cs <[email protected]> wrote: > Hello, How are you? > > I am suck with Django Rest framework issue. > > I am trying to use `request.user` in Django Rest Framework middleware. > > It returns AnonymousUser and I failed. > > I have searched and searched but there is no answer. > > I wonder if this is Django Rest framework issue. > > Who faced this issue? And did you solve? > > Thank you. > > -- > You received this message because you are subscribed to the Google Groups > "Django REST framework" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-rest-framework/4c08081d-0706-4b70-b252-63f8ca8f7d17%40googlegroups.com > <https://groups.google.com/d/msgid/django-rest-framework/4c08081d-0706-4b70-b252-63f8ca8f7d17%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/CALqbk1S_iWwKT5z86-L9KcbPjJB9pPHQVXvALCj8A4rqpV1dPw%40mail.gmail.com.
