开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜