# Buggy code
def get(self, request, *args, **kwargs):
    self.search_handler = self.get_search_handler(
        self.request.GET, request.get_full_path(), []
    )
    return super(CatalogueView, self).get(request, *args, **kwargs)


# Traceback (ValueError)
Traceback (most recent call last):

File "/var/www/oscar/virtualenvs/latest/local/lib/python2.7/site-packages/Django-1.6.6-py2.7.egg/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/var/www/oscar/virtualenvs/latest/local/lib/python2.7/site-packages/Django-1.6.6-py2.7.egg/django/contrib/auth/decorators.py", line 22, in _wrapped_view
return view_func(request, *args, **kwargs)

File "/var/www/oscar/virtualenvs/latest/local/lib/python2.7/site-packages/Django-1.6.6-py2.7.egg/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)

File "/var/www/oscar/virtualenvs/latest/local/lib/python2.7/site-packages/Django-1.6.6-py2.7.egg/django/views/generic/base.py", line 87, in dispatch
return handler(request, *args, **kwargs)

File "/var/www/oscar/builds/latest/oscar/apps/catalogue/views.py", line 123, in get
self.request.GET, request.get_full_path(), [])

File "/var/www/oscar/builds/latest/oscar/apps/catalogue/views.py", line 127, in get_search_handler
return get_product_search_handler_class()(*args, **kwargs)

File "/var/www/oscar/builds/latest/oscar/apps/catalogue/search_handlers.py", line 38, in __init__
super(ProductSearchHandler, self).__init__(request_data, full_path)

File "/var/www/oscar/builds/latest/oscar/apps/search/search_handlers.py", line 54, in __init__
self.results, request_data)

File "/var/www/oscar/builds/latest/oscar/apps/search/search_handlers.py", line 119, in paginate_queryset
'message': str(e)

ValueError: Invalid page (2): That page contains no results


<WSGIRequest
path:/en-gb/catalogue/,
GET:<QueryDict: {u'selected_facets': [u'price_exact:[60 TO *]'], u'page': [u'2']}>,
POST:<QueryDict: {}>,
COOKIES:{},
META:{'CONTENT_LENGTH': '',
'CONTENT_TYPE': '',
u'CSRF_COOKIE': u'LhkCNs5r9tuy3OMshbqaiyzbQXg31CHf',
'DOCUMENT_ROOT': '/etc/nginx/html',
'HTTP_ACCEPT': '*/*',
'HTTP_ACCEPT_ENCODING': 'gzip, x-gzip',
'HTTP_CONNECTION': 'close',
'HTTP_HOST': 'latest.oscarcommerce.com',
'HTTP_USER_AGENT': 'Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)',
'HTTP_X_FORWARDED_FOR': '68.180.225.33',
'HTTP_X_REAL_IP': '68.180.225.33',
'PATH_INFO': u'/en-gb/catalogue/',
'QUERY_STRING': 'selected_facets=price_exact%3A%5B60+TO+%2A%5D&amp;page=2',
'REMOTE_ADDR': '68.180.225.33',
'REMOTE_PORT': '',
'REQUEST_METHOD': 'GET',
'REQUEST_URI': '/en-gb/catalogue/?selected_facets=price_exact%3A%5B60+TO+%2A%5D&amp;page=2',
u'SCRIPT_NAME': u'',
'SERVER_NAME': 'sandbox.oscar.tangentlabs.co.uk',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.0',
'uwsgi.node': 'tangent-oscar-demo.tangentlabs.co.uk',
'uwsgi.version': '1.9.21.1',
'wsgi.errors': <open file 'wsgi_errors', mode 'w' at 0x14436f0>,
'wsgi.file_wrapper': <built-in function uwsgi_sendfile>,
'wsgi.input': <uwsgi._Input object at 0x36e8fd8>,

# Fixed code
def get(self, request, *args, **kwargs):
    try:
        self.search_handler = self.get_search_handler(
            self.request.GET, request.get_full_path(), []
        )
    except InvalidPage:
        # Redirect to page one.
        messages.error(request, _("The given page number was invalid."))
        return redirect("catalogue:index")
    return super(CatalogueView, self).get(request, *args, **kwargs)