Best way to create a Purchase Order App?

32 views
Skip to first unread message

Alexander Joseph

unread,
Jul 10, 2018, 1:24:33 PM7/10/18
to Django users
I'm trying to think of how I would make a purchase order app, where the purchase order itself has its details/information (vendor name, shipping type, payment terms, etc.) but it also has an unspecified (could be 1, could be 10, could be 20) actual purchase items with their own details/information (qty., description, price per unit, etc.). 

Pretty sure on the model side I would just make two seperate models, one for purchase orders and one for purchase items with a ForeignKey to relate the purchase items back to its corresponding purchase order, but on the view side (I'm using CBVs) would you just include both models in the CreateView/UpdateView/DeleteView? And on the template side I'm having trouble thinking how this would work, other than first creating your purchase order, then having some sort of frankenView for the purchase order DetailView/CreateView for purchase items. Thats the only solution I can think of without a bunch of fancy AJAX to put a form for the purchase items inside the CreateView form for the purchase order. Does anyone know of a better way to do this?? Thanks!

oon arfiandwi

unread,
Jul 10, 2018, 2:46:07 PM7/10/18
to django...@googlegroups.com

Hi,

I have similar app which I implement with Django (FBV not CBV, but actually it would be similar).
My approach is using Django Formset, which I generate the Purchase Order View with forms.modelform_factory() [1]
and the Purchase Detail View with forms.inlineformset_factory() [2]

but still, to have the Detail View dynamic (Add/Del items), you need bunch of Ajax.

hope it helps.


-- 
sincerely,
oon

On Wed, Jul 11, 2018 at 1:24 AM Alexander Joseph <Alexander...@gmail.com> wrote:
I'm trying to think of how I would make a purchase order app, where the purchase order itself has its details/information (vendor name, shipping type, payment terms, etc.) but it also has an unspecified (could be 1, could be 10, could be 20) actual purchase items with their own details/information (qty., description, price per unit, etc.). 

Pretty sure on the model side I would just make two seperate models, one for purchase orders and one for purchase items with a ForeignKey to relate the purchase items back to its corresponding purchase order, but on the view side (I'm using CBVs) would you just include both models in the CreateView/UpdateView/DeleteView? And on the template side I'm having trouble thinking how this would work, other than first creating your purchase order, then having some sort of frankenView for the purchase order DetailView/CreateView for purchase items. Thats the only solution I can think of without a bunch of fancy AJAX to put a form for the purchase items inside the CreateView form for the purchase order. Does anyone know of a better way to do this?? Thanks!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5786952d-a28a-4dbc-abc2-9d79153d3ded%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages