Tuesday, February 28, 2012

Re: Can't get pagination to work in django.!!!

hey tom its still not working :P it was easier for me to copy it from
the docs...i still get the same error

template:
<h2>Entries</h2>
<ul>
{% for entry in entries %}
<li><a href="{{ entry.link }}" >{{ entry.title }}</a>
{{ entry.posted }} {{ entry.submitter }}</li>
{% endfor %}
</ul>
<div class="pagination">
<span class="step-links">
{% if entries.has_previous %}
<a href="?
page={{ entries.previous_page_number }}">previous</a>
{% endif %}

<span class="current">
Page {{ entries.number }} of
{{ entries.paginator.num_pages }}.
</span>

{% if entries.has_next %}
<a href="?page={{ entries.next_page_number }}">next</a>
{% endif %}
</span>
</div>
On Feb 28, 5:01 pm, Tom Evans <tevans...@googlemail.com> wrote:
> On Tue, Feb 28, 2012 at 2:45 PM, Tony Kyriakides
>
>
>
>
>
>
>
>
>
> <tonykyriaki...@gmail.com> wrote:
> > I get this error:
>
> > Template error
>
> > In template /home/tony/Documents/vidupdate/templates/index.html, error
> > at line 24
>
> > Caught TypeError while rendering: 'Page' object is not iterable
> > 14      {% else %}
> > 15      <li><a href="/register" >Register</a></li>
> > 16      <li><a href="/login">Login</a></li>
> > 17      {% endif %}
> > 18      <li><a href="/feedback">feedback</a></li>
> > 19      <li><a href="/contact" >Contact</a></li>
> > 20      </ul>
> > 21      <br />
> > 22      <h2>Entries</h2>
> > 23      <ul>
> > 24      {% for entry in entries %}
> > 25      <li><a href="{{ entry.link }}" >{{ entry.title }}</a>
> > {{ entry.posted }} {{ entry.submitter }}</li>
> > 26      {% endfor %}
>
> https://docs.djangoproject.com/en/1.3/topics/pagination/#using-pagina...
>
> Compare and contrast what you are doing with 'entries' in that for
> loop and what the docs do with the equivalent object in the linked
> example, 'contacts'.
>
> Your pagination links are referring to 'contacts' rather than
> 'entries' - copy/paste error there?
>
> Cheers
>
> Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment