我有以下字典:
results[calendar.month_name[date_cursor.month]] = [e,z]
我的网址是:
url(r'^company/(?P<pk>\d+)/purchasedelete/(?P<month>\d+)/date/(?P<pk3>\d+)/$',views.purchase_register_datewise,name='purchase_datewise'),
我的观点:
def purchase_register_datewise(request,month,pk,pk3):
company_details = get_object_or_404(Company, pk=pk)
selectdatefield_details = get_object_or_404(Selectdatefield, pk=pk3)
result = Purchase.objects.filter(Company=company_details.pk, date__month=month, date__gte=selectdatefield_details.Start_Date, date__lt=selectdatefield_details.End_Date)
context = {
'company_details' : company_details,
'selectdatefield_details' : selectdatefield_details,
'result' : result,
}
return render(request, 'stockkeeping/purchase/Purchase_Register_Datewise.html', context)
在我的模板中:
{% for key, value in data %}
<tr>
<td><center><a href="{% url 'stockkeeping:purchase_datewise' pk=company_details.pk month={{ key }} pk3=selectdatefield_details.pk %}"></a>{{ key }}</center></td>
{% if value.0 == 0 %}
<th><center></center></th>
{% else %}
<td><center>{{ value.0 }}</center></td>
{% endif %}
<th><center></center></th>
{% if value.1 == 0 %}
<th><center></center></th>
{% else %}
<td><center>{{ value.1 }} Dr</center></td>
{% endif %}
</tr>
{% endfor %}
当我尝试做month={{ key }}
它会向我抛出这样的错误,Could not parse the remainder: '{{' from '{{'
谁能告诉我如何在模板中传递密钥的值。
谢谢