关于4-5文章详情页跳转的问题
路由
path('detail/<int:article_id>', app01.views.get_detail_page)
index 配置
<div class="col-md-9" role="main"> <div class="body-main"> {% for article in article_list %} <div> <h2><a href="/app01/detail/{{article.article_id}}">{{article.title}}</a></h2> <p>{{article.content}}</p> </div> {% endfor %} </div> </div>
views
def get_detail_page(request,article_id): all_article =Article.objects.all() for article in all_article: if article.arcticle_id == article_id: curr_article=article break return render(request,'app01/detail.html', { 'curr_article':curr_article })
直接访问文章详情页是访问正常
[15/Apr/2020 14:53:18] "GET /app01/detail/4 HTTP/1.1" 200 1344
但在index首页跳转没有获取到id