运行失败啊
previous_article = all_article[previous_index] next_article = all_article[next_index]
这两句上哪去了
def get_detail_page(request, article_id): all_article = Article.objects.all() curr_article = None previous_article = None next_article = None for index, article in enumerate(all_article): if index == 0: previous_index = 0 next_index = index + 1 elif index == len(all_article) - 1: previous_index = index - 1 next_index = index else: previous_index = index - 1 next_index = index + 1 previous_article = all_article[previous_index] next_article = all_article[next_index] 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, 'previous_article': previous_article, 'next_article': next_article })
我是这样的