Добавил возможность добавить опционально metrics.html

This commit is contained in:
Viner Abubakirov
2026-01-04 20:13:54 +05:00
parent 53c5c84d64
commit 9d8f881b7a
3 changed files with 17 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
from django import template
from django.template.loader import get_template
from django.template import TemplateDoesNotExist
register = template.Library()
@register.simple_tag(takes_context=True)
def include_if_exists(context, template_name):
try:
tpl = get_template(template_name)
return tpl.render(context.flatten())
except TemplateDoesNotExist:
return ""