'django framework: is it possible to link 2 tables using a link table?
I am using Django framework and I have the following models:
class AccountUser(AbstractUser):
"""
A user belonging to an account
"""
account = models.ForeignKey('Account', related_name='users', on_delete=models.CASCADE,
default=settings.DEFAULT_ACCOUNT_PK)
@property
def roles(self):
roles = [role.name for role in self.profile.roles.all()]
return roles
class Meta:
ordering = ('username', )
def __str__(self):
return self.username
and
class RigApp(models.Model):
"""
A RIG app
"""
name = models.CharField(max_length=100, unique=True)
description = models.CharField(max_length=100, unique=True)
def __str__(self):
return f'{self.name} - {self.description}'
An account can have more than one App assigned to them. How do I create a Model(table) that link together AccountUser.id and RigApp.id?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
