Infinite scroll in django

爱⌒轻易说出口 提交于 2019-12-03 06:16:26
mtnpaul

We used django endless pagination on www.mymommemories.com without too much problem. Because we were using html5media we did have to add a line to run that function with a one second delay. (setTimeOut("html5media()", 1000). Running it without the delay caused problems in some browsers. If your not using html5media, this should not be a concern however.

Core part of the template code.

{% load endless %}
{% paginate memories %}
{% for memory in memories %}
.
.
.
{%  endfor %}
{%  show_more %}

In the view we have the following to handle the ajax request.

if request.is_ajax():
    template = page_template
    return render_to_response(template,context,context_instance=RequestContext(request))

The page_template is not the whole page, just the portion related to the "paging".

I thinks the easiest way to do endless pagination is use jQuery (use $.loads). You even don't need change the back-end code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!