Add DDT panel for template performance
This commit is contained in:
parent
b882bc44dd
commit
5c8caf37c0
3 changed files with 8 additions and 3 deletions
|
@ -6,3 +6,4 @@ chrono
|
|||
django-debug-toolbar
|
||||
django-jinja
|
||||
jinja2-simple-tags
|
||||
django-debug-toolbar-template-profiler
|
||||
|
|
|
@ -7,6 +7,7 @@ from pathlib import Path
|
|||
import os.path
|
||||
from django.template import engines
|
||||
from django_jinja.backend import Origin
|
||||
from django.conf import settings
|
||||
|
||||
class Tag(models.Model):
|
||||
__yamdl__ = True
|
||||
|
@ -75,9 +76,11 @@ class Page(models.Model):
|
|||
if cached_template := self._template_cache.get(self.slug):
|
||||
return cached_template
|
||||
|
||||
template_name = Path(self.file_path).relative_to(settings.YAMDL_DIRECTORIES[0])
|
||||
|
||||
template = engines["jinja2"].from_string(self.content)
|
||||
template.origin = Origin(name=self.slug, template_name=self.slug)
|
||||
template.name = self.slug
|
||||
template.origin = Origin(name=self.file_path, template_name=template_name)
|
||||
template.name = template.template.name = template_name
|
||||
|
||||
if not self.runtime_render:
|
||||
self._template_cache[self.slug] = template
|
||||
|
|
|
@ -239,7 +239,7 @@ if "ENABLE_ADMIN" in os.environ:
|
|||
|
||||
|
||||
if "ENABLE_DDT" in os.environ:
|
||||
INSTALLED_APPS.append("debug_toolbar")
|
||||
INSTALLED_APPS.extend(["debug_toolbar", "template_profiler_panel"])
|
||||
MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")
|
||||
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
|
@ -260,4 +260,5 @@ if "ENABLE_DDT" in os.environ:
|
|||
# 'debug_toolbar.panels.signals.SignalsPanel',
|
||||
# 'debug_toolbar.panels.redirects.RedirectsPanel',
|
||||
# 'debug_toolbar.panels.profiling.ProfilingPanel',
|
||||
"template_profiler_panel.panels.template.TemplateProfilerPanel"
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue