Answer the question
In order to leave comments, you need to log in
How to create one ForeignKey for two tables at once?
There are two simple tables:
class WorkerMan(models.Model):
name = models.CharField('Имя', max_length=20)
age = models.PositiveSmallIntegerField('Возраст')
class WorkerWoman(models.Model):
name = models.CharField('Имя', max_length=20)
age = models.PositiveSmallIntegerField('Возраст')
class Director(models.Model):
name = models.ForeignKey((WorkerMan, WorkerWoman), on_delete=models.DO_NOTHING)
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