【问题标题】:How to make and submit multiple Django forms?如何制作和提交多个 Django 表单?
【发布时间】:2014-11-16 02:12:33
【问题描述】:

我有这两个模型,我想在一个页面中附加多个“Detalle compra”,然后将它们一起发送。我在管理员中看到了这种行为,但我想这样做。

class Compra(models.Model):
     provedor = models.ForeignKey(Provedor)
     fecha = models.DateTimeField(auto_now_add=True)

class DetalleCompra(models.Model):

    compra = models.ForeignKey(Compra)
    producto = models.ForeignKey(Producto)
    precio_compra = models.DecimalField(max_digits=11, decimal_places=2)
    cantidad = models.DecimalField(max_digits=15,decimal_places=4)

【问题讨论】:

    标签: django multiple-forms


    【解决方案1】:

    我会看看 Django 表单集。我相信这正是您正在寻找的行为。

    https://docs.djangoproject.com/en/dev/topics/forms/formsets/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-08
      • 2021-10-10
      • 1970-01-01
      • 2013-02-13
      • 2013-08-19
      • 2010-10-26
      • 2019-07-06
      • 2017-05-03
      相关资源
      最近更新 更多