I need help understanding the flow of saving an object when using Model
Forms and Create Views.

I am using a CreateView class and a Model Form to create the line item of
an invoice and the parent invoice as part of the same user process. - It's
one step as far as the user is concerned.

The parent invoice data can be mostly inferred, i.e, current date, current
user, etc. There is some data that I collect on the line item form, that
is, it's posted, but not part of the Form design itself, I'm manually
adding the fields to the template.  Specifically, the "payer" information
is posted, but isn't part of the line-item form (it's a foreign key in the
invoice table)

I need to create the Invoice before I can save the line item object.

I'm not clear on where in the event chain I should add the Invoice record
creation.  I don't think I can access the request in the form methods,
otherwise I might do it in the form save method, or maybe the
clean_invoice() method.

Without the invoice data I don't get to form_valid in my view.

I'm also gathering payment information, which lives in another 'many'
table. I think I'll be able to process that in the form_valid method of the
view, but I'm not there yet.

I've cobbled all of this using function views in other parts of the
project, manually grabbing post values, etc. but I'm circling back here
because I know I have more to learn about how I think django wants to work.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BePoMzHhnwL-h%2BcDvvwBg_gOsoUkEPX9nq%2Bxa_1Ufk2zqFRbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to