Amit Buyo
Amit Buyo

Reputation: 25

How to render contents of two models in a single template where one model is linked by Foreign Key through another in django?

I am trying to create a site for financial purpose. I have two models "Company" and "Reports". Reports model has a foreign key linked to Company. I want to render contents of Company and Reports in a single template in a detail view. When i try to render only one of the model's content is shown not both.. Is there any solution to this?

Upvotes: 0

Views: 70

Answers (1)

Ryan Thomas
Ryan Thomas

Reputation: 536

It's hard giving a better example without more details but it would look something like this...

    {{ reports_object.company_foreignkey.company_field }}

Upvotes: 2

Related Questions