middleware updates request.user, but request.user becomes AnonymousUser in view
问题 I wrote a simple JWT middleware to get user from the JWT. The method get_user_from_jwt returns a User object. # app.middlewares.py class JwtMiddleware: def __init__(self, get_response): self.get_response = get_response def __call__(self, request): self.process_request(request) return self.get_response(request) def process_request(self, request): request.user = self.get_user_from_jwt(request.headers) def get_user_pk_from_jwt(self, auth_header: str) -> int: _, token = auth_header.split(' ')