2
儘管存在數據,但以下模板不會輸出任何內容。Django模板:如何在頁面上完全轉儲對象
我的問題是...在那裏我是我可以傾銷到模板的'點'對象的內容,所以我可以看到它是什麼?
template.py
<h3>{% trans "Points" %}</h3>
{% if points %}
<p>{% trans "Total Points" %}: {{ points.Points }}</p>
<table>
<thead>
<tr>
<th>{% trans "Transaction" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Points" %}</th>
</tr>
</thead>
<tbody>
{% for item in points.Points_items.all %}
<tr>
<td>{{ item.transaction_description }}</td>
<td>{{ item.get_status_display }}</td>
<td>{{ item.points }}</td>
</tr>
{% endfor %}
</tbody>
</table>
我剛剛得到這個[<點數:Points對象>,<點數:Points對象>]這是否意味着其空然後? – Prometheus
沒什麼?或者其他的東西?如果你想讓它逐項列出點的內容,可以創建一個'__str__'或'__unicode__'方法。 –
@JohnMee Oooh,有人有態度問題。 – igneosaur