Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paginate_by ListView confliction fix #960

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion django_tables2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_table_pagination(self, table):
paginate = {}

# Obtains and set page size from get_paginate_by
paginate_by = self.get_paginate_by(table.data)
paginate_by = self.get_paginate_by(table.data) or self.get_paginate_table_by(table.data)
if paginate_by is not None:
paginate["per_page"] = paginate_by

Expand Down Expand Up @@ -73,6 +73,18 @@ def get_paginate_by(self, table_data) -> Optional[int]:
"""
return getattr(self, "paginate_by", None)

def get_paginate_table_by(self, table_data) -> Optional[int]:
"""
Alternate method for setting paginate_by that does not conflict with ListView

Args:
table_data: The table's data.

Returns:
Optional[int]: Items per page or ``None`` for no pagination.
"""
return getattr(self, "paginate_table_by", None)


class SingleTableMixin(TableMixinBase):
"""
Expand Down