What I’m looking for is that a many users can be part of a tenant, so my idea in the beginning was to foreign key from user to tenant but I can’t found how to do this. This is what I have at the moment:
models.py
class Tenants(models.Model):
empresa = models.CharField(max_length=60, null=False, blank=False)
sub_dominio = models.CharField(max_length=60, null=True, blank=True)
usuario = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=CASCADE)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.CharField(max_length=20, null=False, blank=False)
class Meta:
verbose_name_plural = "Tenants"
def __str__(self):
return self.empresa
But with this solution I can only have a User per Tenant, how can I do Many users per tenant?