Skip to content

Commit

Permalink
Fixing Paginator warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris May committed Oct 31, 2019
1 parent 1ec2af1 commit 47cb76f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions wagtailmedia/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.core.paginator import Paginator

DEFAULT_PAGE_KEY = 'p'


def paginate(request, items, page_key=DEFAULT_PAGE_KEY, per_page=20):
paginator = Paginator(items, per_page)
page = paginator.get_page(request.GET.get(page_key))
return paginator, page
2 changes: 1 addition & 1 deletion wagtailmedia/views/chooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from wagtail.admin.modal_workflow import render_modal_workflow
from wagtail.admin.utils import PermissionPolicyChecker
from wagtail.core.models import Collection
from wagtail.utils.pagination import paginate

from wagtailmedia.models import get_media_model
from wagtailmedia.permissions import permission_policy
from wagtailmedia.utils import paginate

if WAGTAIL_VERSION < (2, 5):
from wagtail.admin.forms import SearchForm
Expand Down
2 changes: 1 addition & 1 deletion wagtailmedia/views/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
from wagtail.admin.utils import PermissionPolicyChecker, permission_denied, popular_tags_for_model
from wagtail.core.models import Collection
from wagtail.search.backends import get_search_backends
from wagtail.utils.pagination import paginate

from wagtailmedia.forms import get_media_form
from wagtailmedia.models import get_media_model
from wagtailmedia.permissions import permission_policy
from wagtailmedia.utils import paginate

if WAGTAIL_VERSION < (2, 5):
from wagtail.admin.forms import SearchForm
Expand Down

0 comments on commit 47cb76f

Please # to comment.