Виджет для формы выбора зеркал
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user