Django Multi-Table Inheritance VS Specifying Explicit OneToOne Relationship in Models

后端 未结 5 2105
萌比男神i
萌比男神i 2021-01-30 11:53

Hope all this makes sense :) I\'ll clarify via comments if necessary. Also, I am experimenting using bold text in this question, and will edit it out if I (or you) find it distr

5条回答
  •  無奈伤痛
    2021-01-30 12:17

    I don't think I would inherit the User model, rather use a custom UserProfile - leaving the contrib.auth model alone. With the custom UserProfile model, you could setup a base user profile model that can be a part of all your different user types.

    Just looking at it quickly, too, I would look carefully at any models that repeat all the same fields (like your last two Principle and Administrator models). Combining the built in group functionality with the user profile idea may do what you are looking for.

提交回复
热议问题