首页 > 关于 Django 中 models.py 关联表的 form怎么写?

关于 Django 中 models.py 关联表的 form怎么写?

有多个产品a,b,c,d...n
有多个工厂A,B,C...N
A生产a,b,d
B生产c,d
...
这种关系,每个产品-工厂有不同的价格
models.py 大概是下面这样可以吗? form表应该怎么写?
Product(models.Model)
Price (models.Model)
Factory(models.Model):
price = models.ForeignKey(Price)
product = models.ForeignKey(Product)
factory = models.SmallIntegerField(max_length=4)
还是直接在Price表里添加项(产品ID和价格的元组)比较好?

【热门文章】
【热门文章】