Answer the question
In order to leave comments, you need to log in
How to make such a connection?
There are ordinary users ( performers ). And there are projects , and projects have modules , and a project has performers . Several performers can participate in one project. And one project can have several modules. But the modules have one executor.
How can you make a connection like this?
status_choice = (
(0, 'Not ready'),
(1, 'Ready')
)
class Project(models.Model):
name = models.CharField(max_length=200)
price = models.IntegerField()
user = models.ManyToManyField(User, verbose_name='Executors')
status = models.IntegerField(default=0, choices=status_choice)
start_date = models.DateTimeField(blank=True, null=True)
end_date = models.DateTimeField(blank=True, null=True)
def __str__(self):
return self.name
class Module(models.Model):
name = models.CharField(max_length=200)
project = models.ForeignKey(Project, on_delete=models.CASCADE)
user = models.ForeignKey(Project.user, verbose_name='Executor')
start_date = models.DateTimeField(blank=True, null=True)
end_date = models.DateTimeField(blank=True, null=True)
status = models.IntegerField(default=0, choices=status_choice)
def __str__(self):
return self.name
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question