[Fixed]-Django: Creating child users for a project to access data specific to company related to users

1👍

in first place, if you want multiple users connected to single company it’s not going to work with OneToOneField.

I suggest to make a FK from user to company (assuming single user can access only one company) and if you want to make this first user have special permissions (so that the others will not be able to add users) you can make OneToOne field from company to user to point a managing user.

Also, personally I think assuming single user can access one company is a wrong solution. What about users that manager invoices for multiple companies (like account managers)? In that case a single m2m relation would do the trick and in the intermediary table you can put information about user’s permissions.

Leave a comment