Я пытаюсь отобразить многие стороны отношений в подробном представлении в Django.Транзакция может иметь много продаж.
мой взгляд ниже:
класс TransactionDetailView (DetailView): модель = транзакция
URL-адрес ниже: путь ('транзакция //', TransactionDetailView.as_view (), name ='action-detail '),
HTML ниже:
<h1> Transaction</h1>
<br/>
<div class = "row">
<div class = "col-md-12">
<h4>Purchased Coins</h4>
<table class="table">
<thead>
<tr>
<th scope="col">Coin</th>
<th scope="col">Amount</th>
<th scope="col">per Coin</th>
<th scope="col">Total</th>
<th scope="col">Value Per Coin</th>
<th scope="col">Total Value</th>
<th scope="col">Date Added</th>
<th scope="col">Profit/Loss</th>
<th scope="col">%Profit/Loss</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{object.currency}}</td>
<td>{{object.amount}}</td>
<td>{{object.amount_per_coin}}</td>
<td>{{object.total_price}}</td>
<td><p>Get From API</p></td>
<td><p>{{object.amount}} * Get From API</p></td>
<td>{{object.date_purchased|date:"F d, Y"}}</td>
<td><p>TBC</p></td>
<td><p>TBC</p></td>
</tr>
</tbody>
</table>
при попытке создать список продаж, связанных с транзакцией
{% for sale in object.sales %}
<p>kkk</p>
{% endfor %}