Users, Profiles & other things

A common question and/or issue I see new developers get into with Django is a lack of understanding around the User model and what to do about multiple user types (eg Employee & Manager). Below is a brief summary of the available options to deal with.

First off Django only allows one User model for authentication. This is the only model where a password or similar should be defined and it should inherit from one of the Abstract User classes.

Next to differentiate between multiple user types or profile there are three common options I can think of:

  1. Have fields on a Custom User model, either a BooleanField as a flag or a field with choices.
  2. Have related models via a ForeignKey or OneToOneField to your user model
  3. Use Django's Groups & Permissions Models to differentiate between Users.

The above options aren't mutually exclusive but your code would probably be confusing if you did all three. Next week will be dive into each of these options and when to use each one.