【发布时间】:2015-08-27 05:36:02
【问题描述】:
我对 django 很陌生,经过几个小时的尝试,没有任何效果。
我有一个views.py:
class sspView(generic.ListView):
template_name = 'ssp/sspTableView.html'
context_object_name = 'ssp'
message = "yo, this is the message"
def message(request):
return render(request, 'ssp/sspTableView.html', {'message': message})
def get_queryset(self):
return googleData.objects.order_by('date')
我有一个 template.html:
{% if ssp %}
<p>total click is: {{ message }}</p>
<table>
{% for googleData in ssp %}
<tr>
<td>{{ googleData.date }}</td>
<td>{{ googleData.account }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
表格完美呈现,但该消息不会显示。
谢谢。
【问题讨论】:
-
请注意,类名should 通常使用 CapWords 约定。
-
@ErnestTen 我会记住这一点的,谢谢。
标签: python django templates view