![](/img/trans.png)
[英]How to make a filtered summary in django template involving two models linked with foreign key?
[英]How to render contents of two models in a single template where one model is linked by Foreign Key through another in django?
我正在嘗試創建一個用於財務目的的網站。 我有兩個模型“公司”和“報告”。 報告模型有一個與公司鏈接的外鍵。 我想在詳細視圖中的單個模板中呈現公司和報告的內容。 當我嘗試只渲染一個模型的內容時,不會同時顯示兩者.. 有什么解決方案嗎?
在沒有更多細節的情況下很難給出一個更好的例子,但它看起來像這樣......
{{ reports_object.company_foreignkey.company_field }}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.