Ok, you’re starting with an Application.
Given an instance of Application
named application
, then the set of Applicant
would be application.applicant_set.all()
in the view (or application.applicant_set.all
in a template).
Now, if applicants = application.applicant_set.all()
, then for each applicant
within applicants
, applicant.person
is the instance of the Person
object, and applicant.person.address_set.all()
is the collection of all their addresses. Likewise, applicant.person.employment_set.all()
is the set of all Employment
objects associated with that person.
So what you’re likely to end up with are a set of nested loops, where you will iterate through these various details for each on the individual involved.
(Side note: Once you have your desired code working, you will want to add the appropriate prefetch_related
clause to your query to prevent an N + 1
or even a 2N + 1
situation.)