This is a fairly common need in academia, where your users need a different set of profile fields depending on affiliation. And you always end up with edge cases where some people are simultaneously faculty and staff, or even student and faculty, etc. And those "special" people will need to have all of the right fields available to them. You could take an approach something like this:
- Set up standard Groups for Students, Faculty, Staff (and maybe Alumni)
- Have a management command or import script that ensures everyone is in all the right groups
- Set up a shared UserProfile model that includes all shared fields
- For convenience, set up model methods on UserProfile that determine a person's status based on group membership, e.g. `is_faculty()`, `is_student()` etc. (taking care to not interfere with Django' built-in `is_staff` boolean!). This way you can do quick affiliation checks from anywhere (e.g. in templates)
- Set up additional FacultyProfile, StudentProfile, StaffProfile classes with the unique fields and with ForeignKeys to UserProfile
- Either in your import scripts or in save() method or elsewhere, instantiate the additional profile classes:
if user.is_faculty():
fac_profile = FacultyProfile.objects.get_or_create(user=self)
That's very loose and there are many ways to go about it, but that's one possible approach. Another would be to simply put *all* possible fields on UserProfile and just populate them based on affiliation. That's not very clean though, because if someone stops being faculty for instance, it would be tricky to ensure you remove all of the right field data (it's messy). So season to taste.
./s