[Fixed]-Filter objects in admin

1👍

Per the documentation, TabularInline shares methods with ModelAdmin including get_queryset():

class MembershipInline(admin.TabularInline):
    model = Membership
    form = MembershipAdminForm
    extra = 1
    max_num = 1

    def get_queryset(self, request):
        qs = super(MembershipInline, self).get_queryset(request)
        return qs.filter(role=some_query_here)

Leave a comment