Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


How to get objects of model one in model two form which are linked with one to many relationship? In Django

I am having two models Patient and Ipd, both are having different unique id and both are created using Forms , First form creates patient object and I want to create Ipd Form which is linked to Patient with patient id with one to many relationship i.e one patient can have multiple Ipd , I not getting how to get patient objects in Ipd Form and create ipd Object which are linked to Patient , I hope you will understant my problem

1 Answer

Can you post your model code? Do you have a foreign key setup? Typically I would have that setup on the primary side which in this case would be the Patient.