我正在使用model_mommy
Django 创建测试对象。我想实现Recipe
功能。我有一个模型Teacher
和一个模型TeacherSchedule
:
Teacher(models.Model):
some fields ...
TeacherSchedule(models.Model):
teacher = models.OneToOneField(
'Teacher',
on_delete=models.CASCADE,
related_name='schedule',
)
some fields...
我尝试使用的食谱:
schedule = Recipe(
TeacherSchedule,
)
teacher_with_schedule = Recipe(
Teacher,
schedule=foreign_key('schedule'),
)
但是,当我运行测试时,似乎TeacherSchedule
没有创建对象。我做错了Recipe
什么吗?