3

所以我一直在关注这个惊人的应用程序的本教程:http: //django-endless-pagination.readthedocs.org/en/latest/twitter_pagination.html#twitter-page-template

我经历了,修改了views.py部分以适合我的:

@login_required
@page_template('stories/index_story.html')
def index(request, extra_context=None):
story_list = Story.objects.order_by("-date_published")

#FORM
form = StoryForm(initial={'writer': request.user.userprofile, 'date_published': timezone.now()}) ### REMEMBER THIS !!!

template = 'stories/index.html'
page_template = 'stories/index_story.html'

context = {'stories': story_list, 'form': form, 'page_template': page_template}

if extra_context is not None:
    context.update(extra_context)

return render(request, template, context)

启动了服务器。一切看起来都很好,但是当我点击“更多”时,它变成了“正在加载”,什么也没发生。

我从控制台得到错误:

GET http://127.0.0.1:8000/stories/?page=2&querystring_key=page 500 (INTERNAL SERVER ERROR)

我实际上导航到http://127.0.0.1:8000/stories/?page=2&querystring_key=page并加载了其他帖子集。

怎么了?

4

1 回答 1

1

我有同样的问题,在我的情况下,这是一个非常简单的解决方案 - 名称page_template拼写错误,所以 django 找不到它,并给我 500 错误。

于 2015-11-19T08:56:26.790 回答