1

My category.html page is like this right now and the pagination is not working. It doesn't even show any error.

{% autopaginate category.entries.all 5 %}   #line 17
{% for entry in category.entries.all %}
<li><a href="{{ entry.get_absolute_url }}">{{ entry.name }}</a></li>

When on the other hand I change the line 17 in the catehory.html to the following:

{% autopaginate category.entries.all 5 %}   #line 17

it gives me huge template syntax error. http://pastebin.com/E4zfCt0v

I am using pagination using django-pagination on another page too and it is working fine there. I think I am probably not retrieving the entries correctly but if that was the case then {% for entry in category.entries.all %} shouldn't have worked either, which is working fine. I am getting all the entries but it is just not getting paginated on this particular page.

Sushi
  • 631
  • 1
  • 8
  • 19

1 Answers1

2

Looks like the autopaginate tag cannot resolve variable category.entries.all into a valid object (queryset in this case). Quick fix that should work is to pass from your view variable named category_entries (or give it some other name) which will hold already resolved queryset:

category_entries = category.entries.all()

remember to add category_entries to your template context and change category.entries.all to category_entries in your template.

dzida
  • 8,854
  • 2
  • 36
  • 57