1

I got this two models, and I would like to attach multiple "Detalle compra" in one page, and send them all together. I saw this behavior in the administrator, but I would like to do it.

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)

1 Answer 1

1

I would take a look at Django formsets. It's exactly the behavior you are looking for I believe.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.