Form that includes one2many relation

64 views
Skip to first unread message

ctm7

unread,
Feb 15, 2014, 8:13:46 AM2/15/14
to django...@googlegroups.com
Hello Users,

I am currently developing my get to know django project an Invoicing application. I currently developing my forms and I'm trying to figure out how to make a form that allows you to create an invoice *and* at the same time make invoice lines. My invoice line model has a foreign key relation to my invoice model.

This *is* possible within the Admin interface and is as simple as adding an inline view to my InvoiceAdmin model.

Any suggestion for which direction to go in?

Many thanks,

T

C. Kirby

unread,
Feb 17, 2014, 12:17:00 PM2/17/14
to django...@googlegroups.com
I would suggest reading up on inline formsets: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets
You can also look at this stackoverflow question regarding how to use them to create instances, as the docs only talk about editing (and expect you to map those idea to creating):
http://stackoverflow.com/questions/1113047/creating-a-model-and-related-models-with-inline-formsets
Reply all
Reply to author
Forward
0 new messages