[Django]-How to limit the queryset of an inline model in django admin

48👍

Use the get_queryset method:
https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_queryset

Should look like:

class BAdmin(admin.TabularInline):
    ...

    def get_queryset(self, request):
        qs = super(BAdmin, self).get_queryset(request)
        return qs.filter(user=request.user)
👤noamk

Leave a comment