X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/ddaff853c515ef7d188523d9ef17d271901dd581..80d789aa009be1449b83b04b5838ebcc15368d68:/apps/catalogue/utils.py diff --git a/apps/catalogue/utils.py b/apps/catalogue/utils.py index 1ac0ee8d8..106067092 100644 --- a/apps/catalogue/utils.py +++ b/apps/catalogue/utils.py @@ -300,3 +300,16 @@ class AppSettings(object): if hasattr(self, more): value = getattr(self, more)(value) return value + + +def trim_query_log(trim_to=25): + """ +connection.queries includes all SQL statements -- INSERTs, UPDATES, SELECTs, etc. Each time your app hits the database, the query will be recorded. +This can sometimes occupy lots of memory, so trim it here a bit. + """ + if settings.DEBUG: + from django.db import connection + connection.queries = trim_to > 0 \ + and connection.queries[-trim_to:] \ + or [] +