[Django]-Django best user model design

2👍

First, if you want to use email as username, use the Django custom user functionnality. It works well.
Then, note that it’s not because you created your own User that you can’t extend it with a Profile.

So, a good solution could be :

  • Create a Django custom User without trying to add specific fields to it (the one and only purpose here is to use email to log instead of username).
  • Create a PatientProfile class that have a one-to-one relatioship (blank=True) with User class.

This way, a patient that can log in will be related to a User instance and will use this instance for this purpose. On the other hand, the patient who can’t log in won’t be related to any User instance.

In the end, there’s no problem to use OneToMany relationship with PatientProfile for what’s you want to do.

Leave a comment