Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created August 25, 2020 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/1edb71826b4e1310a98746b7fb0acb1b to your computer and use it in GitHub Desktop.
Save velotiotech/1edb71826b4e1310a98746b7fb0acb1b to your computer and use it in GitHub Desktop.
class DynamicPaginationMixin(object):
"""
Controls pagination enable disable option using query param "pagination".
If pagination=false is passed in query params, data is returned without pagination
"""
def paginate_queryset(self, queryset):
pagination = self.request.query_params.get("pagination", "true")
if bool(pagination):
return None
return super().paginate_queryset(queryset)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment