Answer the question
In order to leave comments, you need to log in
Pagination with AJAX in Django?
Hello! Please help me figure it out.
I'm trying to use the django-el-pagination app because it needs AJAX pagination. The page has two blocks with a list of projects. It seems that everything was done according to the docks, but there are 2 problems.
1) It seems to me that ajax does not work, since the entire page is updated and not a specific block.
2) The second problem is very difficult to describe in words, for clarity, I gave screenshots. There are 2 blocks with entries (Currect Projects and Archive Projects). When I go to another page by pagination, such a strange nesting occurs. What am I doing wrong?
home.html:
{% block content %}
<div class="card">
<div class="card-block endless_page_template">
{% include "home/currect_projects.html" %}
</div>
</div>
<div class="card">
<div class="card-block endless_page_template">
{% include "home/archive_projects.html" %}
</div>
</div>
{% endblock %}
{% block script %}
{{ block.super }}
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="{% static 'el-pagination/js/el-pagination.js' %}"></script>
<script>$.endlessPaginate();</script>
{% endblock %}
@page_template('home/currect_projects.html', key='currect_projects')
@page_template('home/archive_projects.html', key='archive_projects')
def home(request, template='home.html', extra_context=None):
context = {
'archive_projects': Project.objects.filter(status='close').order_by('-revision_date'),
'currect_projects': Project.objects.filter(status='open').order_by('-revision_date'),
}
if extra_context is not None:
context.update(extra_context)
return render(request, template, context)
{% load el_pagination_tags %}
{% paginate 1 currect_projects %}
{% for currect_project in currect_projects %}
{{ currect_project.name }}
{{ currect_project.description|truncatewords:20 }}
{% endfor %}
{% show_pages %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question