1👍
✅
Likely the simplest way is to annotate it with the name of the store:
from django.db.models import F
@admin.register(Link)
class LinkAdmin(admin.ModelAdmin):
list_display = ['product', 'get_store']
list_filter = ['position__store']
### extend by product_link_qs related name property to make field sortable in the admin
def get_queryset(self, *args, **kwargs):
return (
super()
.get_queryset(*args, **kwargs)
.annotate(storename=F('products__store__name'))
.distinct()
)
@admin.display(description='store name', ordering='storename')
def get_store(self, obj):
return obj.storename or None
Source:stackexchange.com