File: middleware.py

package info (click to toggle)
python-django-debug-toolbar 1%3A5.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,984 kB
  • sloc: python: 6,880; javascript: 631; makefile: 62; sh: 16
file content (17 lines) | stat: -rw-r--r-- 456 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from django.core.cache import cache


class UseCacheAfterToolbar:
    """
    This middleware exists to use the cache before and after
    the toolbar is setup.
    """

    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        cache.set("UseCacheAfterToolbar.before", 1)
        response = self.get_response(request)
        cache.set("UseCacheAfterToolbar.after", 1)
        return response