[Answered ]-Display objects related current user django admin

2👍

You’ve confused the queryset method (used with list_filter) with the get_queryset method:

The get_queryset method on a ModelAdmin returns a QuerySet of all
model instances that can be edited by the admin site. One use case for
overriding this method is to show objects owned by the logged-in
user.

[Emphasis mine]

class ShareAdmin(admin.ModelAdmin):
    list_display = ('title',)
    save_as = True

    def get_queryset(self, request):
        qs = super(ShareAdmin, self).get_queryset(request)
        if request.user.is_superuser:
            return qs
        return qs.filter(owner=request.user)

Leave a comment