
视图函数
#视图函数,返回文章详情页
def get_article_detial(requestss,article_ID):
articles=Article.objects.all();
curr_article=0;
for article in articles:
if article.article_id==article_ID:
curr_article=article_ID;
#break;
#session_list=articles.content.split('\n')
return render(requestss,'blog/detail.html',
{
'article':articles,
#'session_list':session_list
'curr_article':curr_article
});应用路由
urlpatterns=[
path('hello_world',hello_world),
path('content',article_content),
path('Article_List',get_index_page),
#path('Article_detail',get_article_detial)
];前端展示
<div class="container page-header">
<h1>{{ article.title }}
</h1>
</div>
<div class="container page-body">
<div>
<p></p>
</div>
</div>
</body>
</html>备注:之前在视图中写死打开某篇文章是正常的,就是在URL中传参来指定跳转文章详情页,不知道哪步出错了,麻烦老师能够分析下,谢谢
路由配置得有问题哦,没有把相关参数传递到视图函数。