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.

[1]
https://docs.djangoproject.com/en/2.0/topics/forms/modelforms/#modelform-factory-function
[2]
https://docs.djangoproject.com/en/2.0/topics/forms/modelforms/#overriding-methods-on-an-inlineformset

-- 
sincerely,
oon

On Wed, Jul 11, 2018 at 1:24 AM Alexander Joseph <
alexander.v.jos...@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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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
> <https://groups.google.com/d/msgid/django-users/5786952d-a28a-4dbc-abc2-9d79153d3ded%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CACUNLpUwM_uEjNdWiH0c52YOLSQVbYuaMyo9eHEYAFytfWEdQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to