I’m currently developing a Django site in which users can have multiple ‘accounts’, so that they can seamlessly switch between different public profiles when interacting through the site. What I’m designing is likely to attract multiple registrations per person (and won’t be discouraged), I just would like to offer this in such a way as that users can keep the profiles tied together, switch easily and only have to log in once.
The two approaches I’ve thought up so far include:
-
One (
Usermodel +SiteProfilemodel) pair and manyPublicProfilemodels per person.AUTH_PROFILE_MODULEis set to point to theSiteProfilemodel. Issue with this is that I can’t easily use per-object permissions: these will be set on theUserobject and not the public profile, thus permissions to see a page for “PublicProfileA” will also be applied to when the user is masquerading as “PublicProfileB”. -
One
Accountmodel and many (Usermodel +UserProfilemodel) pairs per person.AUTH_PROFILE_MODULEis set to point to theUserProfilemodel. This would have the added benefit of the permissions working as intended, and that I can simply have a Custom Backend that will switch users by authenticating a user by if they are currently logged in as another user that has the sameAccountobject as the Foreign Key. Authentication would happen by reading fields on theAccountobject though, which would mean thepasswordfield on everyUserobject would be wasted. -
As above, but subclassing
AccountfromUser. I’ve been advised strongly against this though (for reasons unclear).
Is there any pitfalls or better approaches to this? Ultimately, should I use the built-in User model as the one-per-person model that identifies a group of public facing profiles (of which these profiles have a FK back to the User object), or use it as the profile itself, linking back to a single Account object for each person?
Yes, I think the best approach would be to have one and only one User per person and several PublicProfile objects that they can “switch” between. This gives the benefit of only one username/password for them and seems to make the most sense with how Django’s auth typically works.