Skip to content
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