我想在管理面板中过滤Django ForeignKey模型。它具有学生资料,并且可以添加主题标记。但是问题是学生想在获得所有学科列表的同时添加自己的分数。但是我想当10年级的学生添加她的分数,而他会看到她的10年级的主题列表。我该如何实施?
class MarksSubjectInstanceInline(admin.TabularInline):
model = Marks
fk_name = 'std_name'
extra = 2
exclude = ['subject_gradepoint', 'subject_gpa','subject_gpa_sub', 'subject_marks', 'subject_total_marks']
@admin.register(StudentInfo)
class StudentAdmin(admin.ModelAdmin):
list_filter = ('std_class', 'std_gender', 'std_group',)
list_display = ('std_name', 'std_class', 'std_group', 'std_gender', 'std_roll')
inlines = [MarksSubjectInstanceInline]
search_fields = ('std_name','std_roll','std_group')
exclude = ['std_total_marks', 'std_gpa','std_grade_point_total_sum','std_marks_with_fail_sub', 'std_grade_point_total_subject_avg', 'std_fail_subject','school_rank','class_rank']