具有父级和多个不同子级模型的Django表单集

时间:2018-07-05 14:45:59

标签: forms django-class-based-views django-2.0 formsets

是否可以通过这种模型创建表单集?

class Parent(models.Model):
    title = models.CharField(max_length=50)

class Child1(models.Model):
    child1_question = models.CharField(max_length=50)
    parent = models.ForeignKey(Parent, null=True, related_name='child1')

class Child2(models.Model):
    child2_question = models.CharField(max_length=50)
    parent = models.ForeignKey(Parent, null=True, related_name='child2')
.
.
.

0 个答案:

没有答案