進入指定的文章詳情頁,返回空白,檢查代碼未發(fā)現(xiàn)異常
視圖函數(shù) #視圖函數(shù),返回文章詳情頁 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 ??????????????????});
應(yīng)用路由
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中傳參來指定跳轉(zhuǎn)文章詳情頁,不知道哪步出錯了,麻煩老師能夠分析下,謝謝
2019-03-30
路由配置得有問題哦,沒有把相關(guān)參數(shù)傳遞到視圖函數(shù)。