{"action":"created","issue":{"url":"https://api.github.com/repos/rkhleics/wagtailmodeladmin/issues/48","repository_url":"https://api.github.com/repos/rkhleics/wagtailmodeladmin","labels_url":"https://api.github.com/repos/rkhleics/wagtailmodeladmin/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/rkhleics/wagtailmodeladmin/issues/48/comments","events_url":"https://api.github.com/repos/rkhleics/wagtailmodeladmin/issues/48/events","html_url":"https://github.com/rkhleics/wagtailmodeladmin/issues/48","id":142344367,"number":48,"title":"hooks for queryset filtering","user":{"login":"Luperi","id":4625424,"avatar_url":"https://avatars.githubusercontent.com/u/4625424?v=3","gravatar_id":"","url":"https://api.github.com/users/Luperi","html_url":"https://github.com/Luperi","followers_url":"https://api.github.com/users/Luperi/followers","following_url":"https://api.github.com/users/Luperi/following{/other_user}","gists_url":"https://api.github.com/users/Luperi/gists{/gist_id}","starred_url":"https://api.github.com/users/Luperi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Luperi/subscriptions","organizations_url":"https://api.github.com/users/Luperi/orgs","repos_url":"https://api.github.com/users/Luperi/repos","events_url":"https://api.github.com/users/Luperi/events{/privacy}","received_events_url":"https://api.github.com/users/Luperi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-21T13:18:11Z","updated_at":"2016-03-21T14:24:22Z","closed_at":null,"body":"Hi, in wagtail 1.4 have been introduced a new hooks [construct_explorer_page_queryset](http://docs.wagtail.io/en/v1.4.1/reference/hooks.html#page-explorer) that allows you to filter page queryset. Could we implement something similar in `wagtailmodeladmin` to filter a model? For example, if I have a \"Order\" model and I want to show only orders inserted by current user. \r\n\r\nI think in `wagtailmodeladmin.views.IndexView` we should do something like `wagtailadmin.views.index` where they use:\r\n\r\n```\r\n# allow hooks to modify the queryset\r\n    for hook in hooks.get_hooks('construct_explorer_page_queryset'):\r\n        pages = hook(parent_page, pages, request)\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/rkhleics/wagtailmodeladmin/issues/comments/199311135","html_url":"https://github.com/rkhleics/wagtailmodeladmin/issues/48#issuecomment-199311135","issue_url":"https://api.github.com/repos/rkhleics/wagtailmodeladmin/issues/48","id":199311135,"user":{"login":"ababic","id":7779588,"avatar_url":"https://avatars.githubusercontent.com/u/7779588?v=3","gravatar_id":"","url":"https://api.github.com/users/ababic","html_url":"https://github.com/ababic","followers_url":"https://api.github.com/users/ababic/followers","following_url":"https://api.github.com/users/ababic/following{/other_user}","gists_url":"https://api.github.com/users/ababic/gists{/gist_id}","starred_url":"https://api.github.com/users/ababic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ababic/subscriptions","organizations_url":"https://api.github.com/users/ababic/orgs","repos_url":"https://api.github.com/users/ababic/repos","events_url":"https://api.github.com/users/ababic/events{/privacy}","received_events_url":"https://api.github.com/users/ababic/received_events","type":"User","site_admin":false},"created_at":"2016-03-21T14:24:22Z","updated_at":"2016-03-21T14:24:22Z","body":"Hi @Luperi. Wagtail hooks exist to give control over what is otherwise fixed functionality. Hooks aren't needed for wagtailmodeladmin, because the whole view / ModelAdmin class is under your control.\r\n\r\nThe best way to achieve this currently, is to override the `get_queryset` method on your ModelAdmin class:\r\n\r\nhttps://github.com/rkhleics/wagtailmodeladmin/blob/master/wagtailmodeladmin/options.py#L236. \r\n\r\nIt takes the `request` as an argument, so you can get the currently logged-in user from that, and filter accordingly. That method returns the 'base' queryset for the index view.... any dynamic filters / ordering will then be applied to that."}}