Tuesday, July 1, 2014

Re: how to saven models dynamically inputted by user in form



On Tuesday, July 1, 2014 5:58:59 PM UTC+5:30, Lachlan Musicman wrote:
Hi Aashita,

There's a couple of things happening here. I'm no expert and this is a
rushed end of evening email.

For getting the obj.save() to work, here:

            cd = form.cleaned_data
            newPI = PurchasedItem()
            newPI.name = cd['quote_item']
            newPI.qty = cd['quote_qty']
            newPI.save()

You now have a new PurchaseItem with a name and a qty.

Having said that, is there a reason you aren't using ModelForms and
Generic Views?

Then there's the PurchaseOrder.  Will there be other PuchaseItems on
the order? Is it ManyToMany?

If it is, it might be better to have the PurchaseOrder Form, with
PurchaseItem as an attached ModelFormset - in that way you can have as
many PIs on you PO as you want.



now new error is coming-
The view librehatti.bills.views.final didn't return an HttpResponse object. It returned None instea

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aa9f7896-e19a-46f5-ae5f-830a0484106e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment