Django Models Polymorphism And Foreign Keys
Solution 1:
I think this is massively over complicated. You don't have customers, users, and organisations. You have Users
with different permissions or access who belong to different organisations (or accounts). You'll probably also have at least one other type of user. Site administrators. Doesn't mean they should be a different class. You implement it something like this:
classUser(models.Model):
role = models.TextField()
defis_administrator(self):
returnself.role == "admin"defcan_create_appointment(self):
returnself.role == "publisher"
It's also possible that the role might be on the organisation? So that all members of of one account have the same permissions. But you can see how that would work.
EDIT, to clarify my reasoning:
When you have a person logged in, Django will give you access to a user. Do you really want to create a situation where you have to constantly consider which type of user you have available? Or do you just want to be able to use the logged in user and modify the accessible urls and available actions based on some simple rules. The latter is much less complicated.
Post a Comment for "Django Models Polymorphism And Foreign Keys"