We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 36bac54 commit 0c60f19Copy full SHA for 0c60f19
bats_ai/core/admin/recording_tag.py
@@ -1,4 +1,5 @@
1
from django.contrib import admin
2
+from django.db.models import Count
3
4
from bats_ai.core.models import RecordingTag
5
@@ -9,5 +10,16 @@ class RecordingTagAdmin(admin.ModelAdmin):
9
10
'id',
11
'user',
12
'text',
13
+ 'recording_count',
14
)
15
search_fields = ('id', 'user', 'text')
16
+
17
+ def get_queryset(self, request):
18
+ qs = super().get_queryset(request)
19
+ return qs.annotate(_recording_count=Count("recording"))
20
21
+ def recording_count(self, obj):
22
+ return obj._recording_count
23
24
+ recording_count.short_description = "Number of recordings"
25
+ recording_count.admin_order_field = "_recording_count"
0 commit comments