Make bookmarks count column in admin sortable (#183)

The Tag view in django admin has a calculated bookmark count column that is unsortable. This fixes it
This commit is contained in:
Fivefold 2021-12-12 22:52:22 +01:00 committed by GitHub
parent d298260122
commit 5287eb3f8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,6 +58,8 @@ class AdminTag(admin.ModelAdmin):
def bookmarks_count(self, obj):
return obj.bookmarks_count
bookmarks_count.admin_order_field = 'bookmarks_count'
def delete_unused_tags(self, request, queryset: QuerySet):
unused_tags = queryset.filter(bookmark__isnull=True)