X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/1405761d13e0ba62db4b1f9a9d5fa1472142b6d0..5345c6e3640cc5f356b55348a5834e3a1987532d:/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 [] +