Fantomas42 / django-blog-zinnia

Simple yet powerful and really extendable application for managing a blog within your Django Web site.
http://django-blog-zinnia.com/
BSD 3-Clause "New" or "Revised" License
2.11k stars 730 forks source link

Pagination Causes ValueError from Breadcrumbs #551

Open jplehmann opened 5 years ago

jplehmann commented 5 years ago

Actual behavior

Upon upgrading several versions of Django and Zinnia, I started seeing exceptions in production for pagination beyond page 1.

IndexError at /blog/
list index out of range

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/app/.heroku/python/lib/python2.7/site-packages/django/template/library.py" in render
  225.         _dict = self.func(*resolved_args, **resolved_kwargs)

File "/app/.heroku/python/lib/python2.7/site-packages/zinnia/templatetags/zinnia.py" in zinnia_breadcrumbs
  327.         path, context_object, context_page, root_name)

File "/app/.heroku/python/lib/python2.7/site-packages/zinnia/breadcrumbs.py" in wrapper
  95.                 breadcrumbs[-1].url = path

Exception Type: IndexError at /blog/
Exception Value: list index out of range
Request information:
USER: AnonymousUser
GET:
page = u'2'

Expected behavior

Goes to page 2.

Steps to reproduce the issue

  1. https://www.morphmarket.com/blog/?page=2

Specifications

Disclaimer

Before submitting an issue make sure you have:

I guess this may be something in my configuration since no one else had this issue, but not sure what that would be.

jplehmann commented 5 years ago

@Fantomas42 any thoughts here? This seems really weird but not too complicated and I'm guessing you'll have ideas right away. Thanks.

joaolsilva commented 5 years ago

In the file breadcrumbs.py, function "handle_page_crumb" try adding to the if before the crash " and breadcrumbs":

if page.number > 1 and breadcrumbs:

jplehmann commented 5 years ago

@joaolsilva thank you very much. I guess no one else but me don't use breadcrumbs.

I have created a PR.