Skip to content

Commit

Permalink
feat(generic): allow to set paginate_by using a table attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Sep 26, 2024
1 parent 82fa96d commit 1cc3792
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apis_core/generic/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import namedtuple
from typing import Optional

from dal import autocomplete
from django import forms, http
Expand Down Expand Up @@ -193,6 +194,13 @@ def get_queryset(self):
queryset = first_member_match(queryset_methods) or (lambda x: x)
return self.filter_queryset(queryset(self.model.objects.all()))

def get_paginate_by(self, table_data) -> Optional[int]:
"""
Override `get_paginate_by` from the tables2 TableMixinBase,
so we can set the paginate_by value as attribute of the table.
"""
return getattr(self.get_table_class(), "paginate_by", None)


class Detail(GenericModelMixin, PermissionRequiredMixin, DetailView):
"""
Expand Down

0 comments on commit 1cc3792

Please sign in to comment.