[Answered ]-Unable to paginate object_list usng django-pagination

2đź‘Ť

âś…

After a very long time I have been able to find out the error I was having with django-pagination. I had the canonical base template which I was extending on all pages.

In the documentation it is written that we require to put {% paginate %} after {% autopaginate object_list %} but no where it was written about the placement of {% autopaginate object_list %} itself.

I had title and body blocks in my template, and I was putting {% autopaginate object_list %} just below the {% extends "base.html" %} and as a result it was not working. I found that I had to put this statement inside the body block and now it is working absolutely fine.

👤Sachin

0đź‘Ť

Can you see the content of your pagination div if you write “Hello, I want a burger” or anything else in there?

Are you sure you have enough Questions to paginate? You could try something like:

    {% autopaginate Questions 2 %}

to make sure that you’ll be paginating at 2 questions/page.

👤scoopseven

0đź‘Ť

Solved as Sachin told above:
I just moved {% load pagination_tags %}{% autopaginate list_objs 10 %}
inside {% block content %} statement (previously it was outside of it, so pagination was invisible. If no errors, but now pages – try to play with it (moving pagination block).

👤mishaikon

Leave a comment