如何修复show_more标记中的查询字符串问题?

时间:2018-02-01 12:39:58

标签: python html django pagination

我在自己的项目中使用django-el-pagination应用程序的滚动分页。

django==django==1.11.5
django-el-pagination==3.1.0

当用户滚动到终端的最后一页时,我会注意到下一个Traceback。在我看来,querystring标记的show_more有问题。你有任何想法如何解决它?!

P.S。正如我所说,只有当用户滚动到最后一页时才会发生此追踪。假设我有5页,所以只有当用户在最后一页时才会发生这个Traceback:

http://127.0.0.1:8000/documents/?page=5&querystring_key=page

错误:

Time: [25/Jan/2018 08:37:38] | LevelName: DEBUG | Module: base | Process: 1148 | Thread: 123145435922432 | Message: Exception while resolving variable 'querystring' in template 'documents/documents.html'.
Traceback (most recent call last):
  File "/Users/nurzhan_nogerbek/Virtualenvs/py2714/lib/python2.7/site-packages/django/template/base.py", line 903, in _resolve_lookup
    (bit, current))  # missing attribute
VariableDoesNotExist: Failed lookup for key [querystring] in u"[{'False': False, 'None': None, 'True': True}, {'csrf_token': <SimpleLazyObject: <function _get_val at 0x109034ed8>>}]

views.py:

from el_pagination.views import AjaxListView

class DocumentListView(AjaxListView):
    context_object_name = 'documents'
    template_name = "documents/main.html"
    page_template = 'documents/documents.html'

    def get_queryset(self):
        documents = Document.objects.all()
        return documents

文件/ main.html中:

<div class="list-group">
    {% include page_template %}
</div>

文件/ documents.html:

{% load el_pagination_tags %}

{% paginate 20 documents %}
{% for document in documents %}
    {% include "documents/list_template.html" %}
{% endfor %}
{% show_more %}

文件/ list_template.html:

<div class="list-group-item">{{document.title}}</div>

以下是使用show_more代码的模板的链接:show_more.html

0 个答案:

没有答案