I'm building a marketplace that allows users to sign up with a company or organization, add or invite other users to that company and manage those users. All users can create listings (products or service).
Currently I have an abstract user model and a company model with a foreign key to the user, which works well if a company only has one user, it looks like this:
class User(AbstractUser):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
phone_number = models.CharField(max_length=15)
email = models.EmailField(unique=True)
objects = UserManager()
def __str__(self):
return self.first_name
class Company(models.Model):
owner = models.ForeignKey(User, on_delete=models.CASCADE)
company_name = models.CharField(max_length=100, unique=True)
company_address = models.CharField(max_length=100, unique=True)
company_website = models.URLField()
company_verified = models.BooleanField(default=False)
def __str__(self):
return self.company_name
What would be the best way to accomplish this, without giving the users permissions to the admin site?
I've looked at using django-organizations, but the documentation seems poor and they don't support postgresql.