# 马莹:导入Django的admin模块,用于后台管理功能 from django.contrib import admin # 马莹:注册模型的地方(后续会在这里注册需要管理的模型) # Register your models here. # 马莹:定义Commands模型的后台管理类 class CommandsAdmin(admin.ModelAdmin): # 马莹:在后台列表页展示的字段:标题、命令、描述 list_display = ('title', 'command', 'describe') # 马莹:定义EmailSendLog模型的后台管理类 class EmailSendLogAdmin(admin.ModelAdmin): # 马莹:在后台列表页展示的字段:标题、收件人、发送结果、创建时间 list_display = ('title', 'emailto', 'send_result', 'creation_time') # 马莹:设置为只读的字段(无法在后台编辑) readonly_fields = ( 'title', # 标题 'emailto', # 收件人 'send_result', # 发送结果 'creation_time', # 创建时间 'content' # 邮件内容 ) # 马莹:重写添加权限方法,禁止在后台手动添加记录 def has_add_permission(self, request): return False