картинки в одну высоту, добавил вывод времени
All checks were successful
Auto-Deploy-Shop / deploy (push) Successful in 7s

генерации и переменной среды
This commit is contained in:
ack_ik
2026-01-26 15:08:24 +03:00
parent 06e714f9f5
commit 6e1a3ca818
7 changed files with 101 additions and 6 deletions

View File

@@ -1,11 +1,34 @@
import os
import time
from django.http import HttpResponse
from django.template.loader import render_to_string
from django.shortcuts import render
from .models import Product
def product_list(request):
items = Product.objects.all()
env_type = os.getenv("ENV_TYPE", "undefined")
return render(request, 'products/list.html', {
# Measure DB query time (force evaluation)
db_start = time.time()
items = list(Product.objects.all())
db_time = time.time() - db_start
# First render to measure render time
ctx = {
'products': items,
'env_type': env_type
})
'env_type': env_type,
'db_time': db_time,
'total_time': None,
}
render_start = time.time()
_ = render_to_string('products/list.html', ctx, request=request)
render_time = time.time() - render_start
total_time = db_time + render_time
# Final render with measured times
ctx['total_time'] = total_time
html = render_to_string('products/list.html', ctx, request=request)
return HttpResponse(html)