Many-to-Many: Model and Django Template

Asked

Viewed 179 times

1

I have the following situation: - Budget - Product - Items in the Budget

I sought the relationship Many-to-Many in Django (1.10), until then quiet, creates in the Template a Multi-select. But if by chance I need, for example, to inform the quantity of the product in the Budget Items the moment I register a new Budget, I couldn’t associate that kind of relationship, especially with Jinja.

The idea is to have a budget registration screen, where I can add products (can be showmodal html), can inform the quantity, discount, etc, and then save everything.

1 answer

3


I do not know if I understand correctly your problem, but using "Inlineformset" does not solve?

https://docs.djangoproject.com/pt-br/1.10/topics/forms/modelforms/#inline-formsets

In addition, it would make no more sense: Budget - Budget Item(Product, Quantity) - Product.

Good luck ;)


[EDIT]

One suggestion is to double the value of the product in the Budget Item, if the price of the product changes in the future the budget will change as well, which is usually not the case.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.