Current situation
- I have 3 apps in my Django project:
auth
,polls
andschool
. AUTH_USER_MODEL
in my settings isauth.models.User
, and it is shared between all apps.- the
login/
URL inurls.py
is also shared between the 3 apps.
What I need to do
I want to add some methods only to the users of the school
app. To do this, I created a school.models.User
model with proxy = True
meta. This model inherits from auth.models.User
.
Problem
When a user logs in, request.user
contains a "base" auth.models.User
object, independently of which app the user is using.
How can I populate request.user
with a different user model, depending on the app?
I tried using a custom Authentication Backend as suggested in Django - User proxy model from request, but I have no way to detect which app the user is using, so I can't seem to discriminate between polls
and school
in the authentication backend.