Tuesday, November 8, 2016

Canonical way of handling multiple types of users? (Profiles vs subclassing django.contrib.auth.models.AbstractUser)

Hi,

What is the current canonical way to handle multiple user-profiles in Django?

For example - say you have "Teachers", "Students", "Parents" - you may have slightly different fields for each one and/or different behaviour. Students will have things like grades, Parents may have 1-to-many Students etc.

I understand you can use a OneToOne field to associated different user profiles with each type of user:

https://docs.djangoproject.com/en/1.10/topics/auth/customizing/#extending-the-existing-user-model

The docs mention using a django.db.models.signals.post_save signal on User, but I'm guessing that won't work here if you have multiple types of users.

Or are you better off subclassing django.contrib.auth.models.AbstractUser? (I get the impression using profile models is less invasive).

Regards,
Victor

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/314de801-0ca7-4eb3-abb9-7a3044994bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment