{"issue":{"user":{"id":1277035,"login":"sgoll","url":"https://api.github.com/users/sgoll","gravatar_id":"17abc0c3764d4c7b98329d3c990ef0e2","avatar_url":"https://secure.gravatar.com/avatar/17abc0c3764d4c7b98329d3c990ef0e2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"milestone":{"creator":{"id":2449,"login":"toastdriven","url":"https://api.github.com/users/toastdriven","gravatar_id":"130de5dce3445b62f84fb4cfc86bfcd4","avatar_url":"https://secure.gravatar.com/avatar/130de5dce3445b62f84fb4cfc86bfcd4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"open_issues":20,"title":"v2.0.0","created_at":"2011-05-03T16:55:24Z","state":"open","due_on":"2011-05-31T07:00:00Z","closed_issues":11,"description":"","number":5,"url":"https://api.github.com/repos/toastdriven/django-haystack/milestones/5"},"title":"Negative index on pagination","created_at":"2011-12-21T07:16:05Z","labels":[],"state":"closed","updated_at":"2011-12-22T06:53:43Z","id":2622377,"html_url":"https://github.com/toastdriven/django-haystack/issues/463","closed_at":"2011-12-22T06:53:43Z","pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"body":"Current master has the following problem. When pagination is active and a page with a non-positive index is requested manually, i.e. for instance `?page=0` or `?page=-1`, an exception is thrown in `haystack/query.py`, method `__getitem__()`: \"Negative indexing is not supported\".\r\n\r\nThis is due to an unchecked queryset slice in `haystack/views.py`, method `build_page()`. Ideally, we would use Django paginator's `validate_number()` method, but since we need `page_no` before actually creating the `Paginator` instance, we must do the check manually.\r\n\r\nI suggest the following patch:\r\n\r\n```\r\ndiff --git a/haystack/views.py b/haystack/views.py\r\nindex 863a790..428297e 100644\r\n--- a/haystack/views.py\r\n+++ b/haystack/views.py\r\n@@ -100,6 +100,9 @@ class SearchView(object):\r\n         except (TypeError, ValueError):\r\n             raise Http404\r\n \r\n+        if page_no < 1:\r\n+            raise Http404\r\n+\r\n         start_offset = (page_no - 1) * self.results_per_page\r\n         self.results[start_offset:start_offset + self.results_per_page]\r\n```","number":463,"url":"https://api.github.com/repos/toastdriven/django-haystack/issues/463","comments":1,"assignee":null},"comment":{"user":{"id":2449,"login":"toastdriven","url":"https://api.github.com/users/toastdriven","gravatar_id":"130de5dce3445b62f84fb4cfc86bfcd4","avatar_url":"https://secure.gravatar.com/avatar/130de5dce3445b62f84fb4cfc86bfcd4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"created_at":"2011-12-22T06:53:43Z","updated_at":"2011-12-22T06:53:43Z","id":3246127,"body":"Good catch! Fixed in SHA: 2c6dff0cdf161c920a884cbf5767fd9fafe84a01 & SHA: d01d9cc91914dcffdf511e0d6ae1048a57b9490b","url":"https://api.github.com/repos/toastdriven/django-haystack/issues/comments/3246127"},"action":"created"}