简体   繁体   中英

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?

在没有更多细节的情况下很难给出一个更好的例子,但它看起来像这样......

    {{ reports_object.company_foreignkey.company_field }}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM