You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
996 B

from django.contrib import admin
from .models import Course, SC
# Register your models here.
admin.site.site_header = '教务系统管理端'
class CourseAdmin(admin.ModelAdmin):
'''设置列表可显示的字段'''
list_display = ('cid', 'name', 'type', 'credit', "tid")
'''设置过滤选项'''
list_filter = ('name', 'credit', 'type')
'''每页显示条目数'''
list_per_page = 5
'''设置可编辑字段'''
list_editable = ('name', 'type', 'credit', "tid")
'''按发布日期排序'''
ordering = ('-credit',)
class ScAdmin(admin.ModelAdmin):
list_display = ('student_name', 'course_name', 'middle_grade', 'end_grade')
list_per_page = 5
def student_name(self, obj):
print(obj)
return obj.sid.name
def course_name(self, obj):
return obj.cid.name
list_editable = ('middle_grade', "end_grade")
ordering = ('-end_grade',)
admin.site.register(Course, CourseAdmin)
admin.site.register(SC, ScAdmin)