编辑文件task_tool/admin.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
# Register your models here.
from .models import Myclass, Student, Task, TaskReport, Teacher, WorkRoom
class WorkRoomAdmin(admin.ModelAdmin):
list_display = ('name',)
class TeacherAdmin(admin.ModelAdmin):
list_display = ('name', 'staff_no')
class MyClassAdmin(admin.ModelAdmin):
list_display = ('name',)
class StudentAdmin(admin.ModelAdmin):
list_display = ('name',)
class TaskAdmin(admin.ModelAdmin):
list_display = ('title', 'content', 'file', 'deadline')
class TaskReportAdmin(admin.ModelAdmin):
list_display = ('student', 'task', 'grade')
admin.site.register(WorkRoom, WorkRoomAdmin)
admin.site.register(Teacher, TeacherAdmin)
admin.site.register(Myclass, MyClassAdmin)
admin.site.register(Student, StudentAdmin)
admin.site.register(Task, TaskAdmin)
admin.site.register(TaskReport, TaskReportAdmin)
注释:
admin.site.register(Task, TaskAdmin) 第一个参数是告诉后台管理页面需要显示哪一个表格,第二个参数TaskAdmin告诉后台管理页面应该显示这个表中的哪些列。
list_display 属性的值是一个元组,用于告诉后台管理页面显示相应的列