-
Notifications
You must be signed in to change notification settings - Fork 40
Description
In my Django application I'm using the django_structlog.middlewares.RequestMiddleware to log all of the requests to my application.
I noticed that user_id is always None for all the calls made to my Django Rest Framework (DRF) urls.
Now, I know this is because RequestMiddleware tries to access request.user, which is only filled in when you're going through the Django authentication mechanism, which DRF bypasses completely. Instead, it performs authentication in the view layer, so after all middleware code has run.
I guess other people have encountered this too so I was wondering if there is any workaround so that I can track which user performed which request from "the start" until "the end" of the request?
I tried several things, but all of them feel like I'm fighting with DRF to get it to do something it doesn't support.