Виджет для формы выбора зеркал

This commit is contained in:
2025-11-13 21:09:39 +03:00
parent 8e0d32c307
commit 5ab6770809
7 changed files with 799 additions and 374 deletions

View File

@@ -37,10 +37,9 @@ class SourceListView(LoginRequiredMixin, View):
date_to = request.GET.get("date_to", "").strip()
# Get all Source objects with query optimization
sources = Source.objects.select_related(
'created_by__user',
'updated_by__user'
).prefetch_related(
# Using annotate to count ObjItems efficiently (single query with GROUP BY)
# Using prefetch_related for reverse ForeignKey relationships to avoid N+1 queries
sources = Source.objects.prefetch_related(
'source_objitems',
'source_objitems__parameter_obj',
'source_objitems__geo_obj'
@@ -164,8 +163,6 @@ class SourceListView(LoginRequiredMixin, View):
'objitem_count': objitem_count,
'created_at': source.created_at,
'updated_at': source.updated_at,
'created_by': source.created_by,
'updated_by': source.updated_by,
})
# Prepare context for template