From 9b800a0529a5bdc2d1083bca8a12d6df3f9b77dc Mon Sep 17 00:00:00 2001 From: erjemin Date: Sat, 11 Apr 2026 16:11:59 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=81=D1=87=D1=91=D1=82=D1=87=D0=B8?= =?UTF-8?q?=D0=BA=20=D0=BF=D1=80=D0=BE=D1=81=D0=BC=D0=BE=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B1=D0=B5=D0=B7=20save?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cadpoint/web/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cadpoint/web/views.py b/cadpoint/web/views.py index 178f621..6876e31 100644 --- a/cadpoint/web/views.py +++ b/cadpoint/web/views.py @@ -3,7 +3,7 @@ import math from django.shortcuts import render, HttpResponseRedirect from django.http import Http404, JsonResponse -from django.db.models import Count, Q +from django.db.models import Count, F, Q from django.views.decorators.http import require_GET # from datetime import datetime from django.utils import timezone @@ -197,8 +197,10 @@ def show_item(request, to_template["PAGE_OF_LIST"] = int(ppage) to_template["ITEMS_AFTER"] = q_items_after to_template["ITEMS_BEFORE"] = q_items_before + # Счётчик просмотров обновляем отдельно от `save()`, чтобы не запускать + # типографизацию, пересборку slug и автообновление `dtContentTimeStamp`. + TbContent.objects.filter(pk=q_item.pk).update(iContentHits=F("iContentHits") + 1) q_item.iContentHits += 1 - q_item.save(update_fields=["iContentHits"]) return render(request, template, to_template) except (ValueError, AttributeError, TbContent.DoesNotExist, TbContent.MultipleObjectsReturned): raise Http404("Контента с таким id не существует")