Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8477709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:32:25+00:00 2026-06-10T18:32:25+00:00

In Django it is quite straight forward to implement a pagination to display the

  • 0

In Django it is quite straight forward to implement a pagination to display the query items on several pages. It is also quite straight forward to utilize Ajax to update only the bits of the page that really have changed, rather than loading the entire page every single time. However I found it a bit problematic when the two are combined.

In the example below the search results shall be shown in the appropriate result_list.html.

<form id="search-form" method="get" action=".">
        {{ form.as_p }}
        <input type="submit" value="search" />
</form>
<div id="search-results">           
       {% include "result_list.html" %}
</div>

result_list.html:

{% if sales_items %}
    {% for item in sales_items %}
            <li>
                <ul>                
                    Search Result...        
                </ul>                               
            </li>       
        {% endfor %}
        {% if show_paginator %}
                <div class="paginator">
                          ...
                  (Page {{ page }} of {{ pages }})
                </div>
        {% endif %}  
{% else %}
    {% trans 'No Items found.' %}
{% endif %}

This solution works very nicely. Because everytime I search (through ajax) for something the result_list.html including the pagination are refreshed.

Problem:

But now if I had a table instead I couldn’t use this approach anymore.

<table class="table">
   <thead>
        <tr>
           <th>...</th>
        </tr>
   </thead>
   <tbody id="search_result">
        {% include 'calls_list.html' %}
   </tbody>
</table>

The page bit that is required to be refreshed is just between the <tbody> tag. Hence Calls_List.html returns only <tr> and <td> tags that is understood by a <tbody>. I simply couldn’t paste the paginator code in there as well (unlike the above example):

    {% if show_paginator %}

      <div class="paginator">
         ...
          (Page {{ page }} of {{ pages }})
      </div>
    {% endif %}  

… since the table’s tbody isn’t expecting to find a div element there.

Unless I do a second round trip to the server to pull the pagination code separately. I couldn’t find a clean solution for this.

Have you been in the same situation, How did you solve this please?

Many Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:32:26+00:00Added an answer on June 10, 2026 at 6:32 pm
    • One solution would be that you put the pagination part in a <tr> but change the visualization as you would like (e.g. only 1 <td> or spanning multiple columns etc.)

    • Another solution would be you change your Calls_list.html to return complete <table> tag and put pagination part out of table in a separate <div>.

    • Third option could be return JSON of rows data along with pagination data. Then just update the existing table rows and pagination html.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm quite new to django, and moved to it from Drupal. In Drupal is
Django happens to have a Signals system built in and it would be quite
I've getting quite fast with a small django project of mine, which I'm developing
I'm attempting to upgrade quite a large Django project to the newly released Django
I'm just starting with django. It is not quite clear to me, how should
Django Endless Pagination works perfectly fine right until I use template inheritance. views.py: from
I need to display an image in a Django form. My Django form is
I'm building a system using django, Sphinx and MySQL that's very quickly becoming quite
I'm thinking a bit about the concept of Django aggregates. I don't quite get
I am quite new with Django, and I was wondering if I could document

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.