报错:Reverse for 'detail' with arguments '(1,)' not found. 1 pattern(s) tried: ['home\\/detail\\/\\<int\\:topic\\.id\\>$']
我的路由:path('detail/<int:topic.id>',views.topic,name='detail')
views:
def topics(requset):
topics = Topic.objects.order_by('date_added')
context = {'topics':topics}
return render(requset,'blog_home/topics.html',context)
模板中:<ul>
{% for topic in topics %}
<li>
<a href="{% url 'detail' topic.id %}">{{ topic }}</a>
</li>
{% empty %}a
<p>no have topic yet.</p>
{% endfor %}
</ul>
views 中函数 topics 传到模板中的字典有 2 个值,新手一直找不到原因求大神解救!
我的路由:path('detail/<int:topic.id>',views.topic,name='detail')
views:
def topics(requset):
topics = Topic.objects.order_by('date_added')
context = {'topics':topics}
return render(requset,'blog_home/topics.html',context)
模板中:<ul>
{% for topic in topics %}
<li>
<a href="{% url 'detail' topic.id %}">{{ topic }}</a>
</li>
{% empty %}a
<p>no have topic yet.</p>
{% endfor %}
</ul>
views 中函数 topics 传到模板中的字典有 2 个值,新手一直找不到原因求大神解救!