Closed Domejko closed 3 weeks ago
Oh i've just seen what you mean, in our middleware we dont even call the additional fetch for profile. Maybe it's somewhere else. I'll check it out now, i could've swore it was here
Ah this is what I was thinking of https://github.com/TreyWW/MyFinances/blob/main/backend/models.py#L41
Problem is that both AuthenticationMiddleware
and CustomUserMiddleware
where using query to fetch the user object. I removed AuthenticationMiddleware
from MIDDLEWARE
and adjusted CustomUserMiddleware
so that it would replace it and populate request.user
with our CustomUser instance.
With this changes we don't get double query issue and user profile is also accessible in request.user
.
Amazing. Does this pass all tests still and everything visually work on the site? Just wondering if any Django packages use the middleware or if they will automatically move over to our new one
Yes it was passing tests on my machine and on website everything work as intended. As for AuthenticationMiddleware
I did check and it looks like it's not used anywhere else in Django.
I will fix that mypy error and will push that PR.
Thanks @Domejko, really appreciate the support recently!
Description
Regarding #267
"django.contrib.auth.middleware.AuthenticationMiddleware"
with"backend.middleware.CustomUserMiddleware"
Checklist
What type of PR is this?
Added/updated tests?
Related PRs, Issues etc