A server error occurred. Please contact the administrator.痛苦!
这个错误?
路由:
urlpatterns = [ path('helloworld', blog.views.helloworld), path('content', blog.views.article_content), path('index', blog.views.get_index_page), # path('detail', blog.views.get_detail_page) path('detail/<int:article_id>', blog.views.get_detail_page) ]
详情页视图:
def get_detail_page(request, article_id): all_article = Article.objects.all() curr_article = None for article in all_article: if article.article_id == article_id: curr_article = article break section_list = curr_article.content.split('\n') return render(request, 'blog/detail.html', { 'curr_article': curr_article, 'section_list': section_list } )
详情页网页:
<body> <div class="container page-header"> <h2>{{ curr_article.title }} </h2> </div> <div class="container body-main"> <div> {% for section in section_list %} <p>{{ section }}</p> {% endfor %} </div> </div> </body>