2017-02-19 168 views
0
class StudentsTeacher(admin.TabularInline): 
    form = StudentsTeacher 
    model = StudentsTeacher 

class Teacher_Admin(admin.ModelAdmin): 
    inlines = (StudentsTeacher,) 

我想在StudentsTeacher中添加一個查詢集並使用過濾器進行選擇,但它不起作用,內聯總是顯示所有內容。如何在Django管理內聯過濾

回答

0

隨着get_queryset()方法,你可以重寫查詢集

class Teacher_Admin(admin.TabularInline): 
    def get_queryset(self, request): 
     qs = super(Teacher_Admin, self).get_queryset(request) 
     return qs.filter(<filtering>) 

你可以閱讀更多關於它的django docs

+0

對不起,我是指過濾器內聯顯示器 –