i have the following models:
class Team(models.Model):
users = models.ManyToManyField("User")
class User(AbstractUser):
...
class Subscription(models.Model):
team = models.ForeignKey("Team", on_delete=models.CASCADE)
name = models.CharField(max_length=64)
class Package(models.Model):
name = models.CharField(max_length=64) # packageA, packageB
max_activation_number = models.PositiveIntegerField(default=1)
class Activation(models.Model):
subscription = models.ForeignKey("Subscription", on_delete=models.CASCADE)
package = models.ForeignKey("Package", on_delete=models.CASCADE)
created = models.DatetimeField()
class PackageA(models.Model):
...
class PackageB(models.Model):
...
A team has one subscription and it can activate one or more package and the same package could be activated more than one time. (number of times specified with "max_ativation_number")
Example:
A team has a subscription called Suite and the available packages are: EmailAccount and Calendar The team choose to activate 3 EmailAccount and 2 Calendar (packages are not tied to each other)
For that reason the team could activate the same package more times.
For every activation i need to create a new instance on PackageA or PackageB (it depends on the choice a team made) and then i should "link" to that instance somehow.
Should i use GenericKey field inside Activation model? I not only need the name of the chosen package but I also need to figure out which instance.
from Link Django models together via GenericKey?
No comments:
Post a Comment