File: loaders.py

package info (click to toggle)
python-django-debug-toolbar 1%3A1.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,480 kB
  • sloc: python: 3,346; makefile: 191; sh: 1
file content (17 lines) | stat: -rw-r--r-- 674 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import django
from django.contrib.auth.models import User
from django.template.loaders.app_directories import Loader


class LoaderWithSQL(Loader):

    if django.VERSION[:2] >= (1, 9):
        def get_template(self, *args, **kwargs):
            # Force the template loader to run some SQL. Simulates a CMS.
            User.objects.all().count()
            return super(LoaderWithSQL, self).get_template(*args, **kwargs)
    else:
        def load_template(self, *args, **kwargs):
            # Force the template loader to run some SQL. Simulates a CMS.
            User.objects.all().count()
            return super(LoaderWithSQL, self).load_template(*args, **kwargs)