Different user profile associated to a each user group

14 views
Skip to first unread message

Alessandro Pasotti

unread,
Mar 11, 2015, 3:50:31 AM3/11/15
to django...@googlegroups.com
Hi,

I've used custom user profiles in the past, but they were associated
to all users, now I need to associate a different custom profile for
each user group (for example: "corporate", "private").

Any hint about the best approach?

--
Alessandro Pasotti
w3: www.itopen.it

Collin Anderson

unread,
Mar 12, 2015, 2:27:12 PM3/12/15
to django...@googlegroups.com
Hi,

I'd personally recommend re-using the same model and having a "type" field for whether it's corporate or private.

Otherwise, you'd need to do something like:

class Corporate(models.Model):
    user
= models.OneToOneField(User)

class Private(models.Model):
    user
= models.OneToOneField(User)

Then, you would need to try to query for the profile. Something like:
try:
    corporate
= request.user.corporate
except Corporate.DoesNotExist:
    corporate
= None

Collin
Reply all
Reply to author
Forward
0 new messages