Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django form - in-place edit of data from reverse foreign key join

I have a Person table and Phone table. The Phone table has a foreign key into the Person table, which is an auto-increment ID. Each person can have an arbitrary number of phone numbers. Is there a way for me to create a Django form to enter phone numbers while creating a new Person entry and edit them along with an existing Person entry?

like image 384
Fred Larson Avatar asked Jan 08 '09 03:01

Fred Larson


1 Answers

Yes, Django's inlineformset_factory is exactly what you need.

Docs: Model Formsets and Inline formsets

This snippet should help you as an example.

like image 133
Van Gale Avatar answered Oct 19 '22 18:10

Van Gale