Skip to content

Commit

Permalink
fix count when using filters
Browse files Browse the repository at this point in the history
  • Loading branch information
laggron42 committed Jan 13, 2025
1 parent d730b4e commit f34d647
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion admin_panel/bd_models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
class ApproxCountPaginator(Paginator):
@cached_property
def count(self):
"""Return the total number of objects, across all pages."""

# if this object isn't empty, then it's a paginator that has been applied filters or search
if self.object_list.query.where.children: # type: ignore
return super().count

with connection.cursor() as cursor:
cursor.execute(
"SELECT reltuples AS estimate FROM pg_class where relname = "
Expand Down

0 comments on commit f34d647

Please sign in to comment.