Добавил возможность добавить опционально 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

1
.gitignore vendored
View File

@@ -176,3 +176,4 @@ cython_debug/
# Django
staticfiles/
metrics.html

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 ""

View File

@@ -24,4 +24,6 @@
</div>
{% block content_extra %}{% endblock %}
</body>
</html>
{% load optional_include %}
{% include_if_exists "metrics.html" %}
</html>