Hi all,
I updated my site to Mezzanine 4.1.0/Django 1.9 yesterday and mostly it
went fairly smoothly.
This morning, however, I was getting errors from the blog app, specifically:
~~~~~
Internal Server Error: /blog/
Traceback (most recent call last):
File
"/home/danny/.virtualenvs/ausdwcon-navi/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 140, in get_response
response = middleware_method(request, callback, callback_args,
callback_kwargs)
File
"/home/danny/.virtualenvs/ausdwcon-navi/local/lib/python2.7/site-packages/mezzanine/pages/middleware.py",
line 95, in process_view
return view_func(request, *view_args, **view_kwargs)
File
"/home/danny/.virtualenvs/ausdwcon-navi/local/lib/python2.7/site-packages/mezzanine/blog/views.py",
line 58, in blog_post_list
settings.MAX_PAGING_LINKS)
File
"/home/danny/.virtualenvs/ausdwcon-navi/local/lib/python2.7/site-packages/mezzanine/utils/views.py",
line 158, in paginate
page_range = page_range[start:start + max_paging_links]
TypeError: sequence index must be integer, not 'slice'
~~~~~~~
I've determined this is happening because I have more than 50 blog posts
in the database, and we display 5 per page with max_paging_links set to 10.
When there's 50 or fewer blog posts to display, the error doesn't occur
- this is because the code doesn't enter the "if len(page_range) >
max_paging_links:" part of the paginate() function. (You can probably
check this by changing BLOG_POSTS_PER_PAGE or MAX_PAGING_LINKS in the
admin settings/miscellaneous - both are editable)
In any case, I did some tracking down - page_range should be a Django
Paginator Page object, which can take a slice as its index parameter
(See e.g. https://code.djangoproject.com/ticket/23140,
https://code.djangoproject.com/ticket/23190,
https://code.djangoproject.com/ticket/23088)
However, it appears that when I'm getting this exception, the page_range
object is of type xrange() - which can't take a slice.
So is there a problem somewhere in mezzanine/utils/views.py that should
be fixed? Or have I made a mistake myself somewhere else?
I'm using Python 2.7.6, so if it's a Python 2 vs 3 thing, we should
probably make sure the code works on both.
My workaround for now will be to change MAX_PAGING_LINKS in my site
settings to something larger.
Thanks for any help,
Seeya. Danny.
--
You received this message because you are subscribed to the Google Groups "Mezzanine
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.