I politely wish to reach out, as I require assistance…
I am building a point-of-sale system in Django, and I have really tried working around the stock transfer part, which is working well, but not as I want it to.
All transfer is working well, but, I can’t transfer multiple entries of products at the same time, only one product and its quantity at a time… but I wanted to be able to transfer multiple products, and their entries at the same time, like, I have an input field for a product and it’s quantity, then I hit “enter”, or click a button to add another input field where I can enter another product and it’s quantity, then, submit this form as one, and have it do the transfer.
I would really appreciate your input on this, please.
You are correct in that a formset is the way you want to do this.
Be aware that if you dynamically add an instance of a form to a formset, you need to ensure that the id and name attributes of the form elements are created correctly and that you adjust the management form as well.
You can search this forum for other threads on this topic to find some examples and other discussions about this.
Well, the challenge I’m facing is that the form set is only providing a static amount of fields, as in, the “extra” is set to 3 by default, and fair enough, I can change any number I want, but that’s the catch-- I don’t want to be the one to add the number, but, on the front-end, when the user clicks some JavaScript button to “Add Product”, that should create another field, which would then still be picked as part of the form, so that upon submission, the entire entries are submitted/transferred.
I would actually say, what I want to do is, override the “extra” parameter of the form sets, so that, instead of having a fixed value, such as “extra=5”, I can have the user create/add the forms from the frontend, and then these are all included as one entire and submitted… to transfer multiple instances of products form at once.