Can I filter instances shown in admin changelist?
I have a model Child inheriting from a model Parent. In the Parent admin I've got Parent and Child instances, while I would like to have only Parent instances (Child instances are managed in Child admin).
How can I do that?
than开发者_C百科ks
jul
Override the queryset
method in your ModelAdmin subclass to only return the objects you need.
class MyParentAdmin(admin.ModelAdmin):
def queryset(self, request):
return Parent.objects.filter(whatever_your_criteria_is=True)
精彩评论