有没有一种通用的方法/最佳实践/任何方法来组合跨越多个相关模型的表单?
我想在同一页面上创建/编辑模型对象以及其他相关的模型对象。基本上,能够创建/编辑一个模型实例和通过外键关联的另一组模型实例。
我知道这不是一个很好的解释。
class Person(models.Model):
name = models.CharField(max_length=64, unique=True)
class PhoneNumber(models.Model):
person = models.ForeignKey(Person)
description = models.CharField(max_length=64, blank=True, null=True)
number = models.CharField(max_length=32, blank=True, null=True)我希望能够使用单个表单/页面创建/编辑一个人,以及他们所有相关的电话号码。
在使用this nested form示例之前,我已经做到了这一点,但它看起来很不靠谱。
发布于 2011-07-13 10:13:25
https://stackoverflow.com/questions/6673341
复制相似问题