[Django]-Django-tables2 flooding database with queries

2๐Ÿ‘

โœ…

Im posting this as a future reference for myself and other who might have the same problem.

After searching for a bit I found out that django-tables2 was sending a single query for each row. The query was something like SELECT * FROM "table" LIMIT 1 OFFSET 1 with increasing offset.

I reduced the number of sql calls by calling query = list(query) before i create the table and pass the query. By evaluating the query in the python view code the table now seems to work with the evaulated data instead and there is only one database call instead of hundreds.

๐Ÿ‘คuser2602386

1๐Ÿ‘

This was a bug and has been fixed in https://github.com/bradleyayers/django-tables2/issues/427

๐Ÿ‘คInti

Leave a comment