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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
from django . contrib import admin
# Register your models here.
class CommandsAdmin ( admin . ModelAdmin ) :
"""
命令管理后台类
用于在Django管理后台中展示和管理命令信息, 配置了列表页面显示的字段
"""
list_display = ( ' title ' , ' command ' , ' describe ' )
class EmailSendLogAdmin ( admin . ModelAdmin ) :
"""
邮件发送日志管理后台类
用于在Django管理后台中展示和管理邮件发送日志信息, 配置了列表页面显示的字段
和只读字段,并重写了权限控制方法
Attributes:
list_display: 列表页面显示的字段元组
readonly_fields: 只读字段元组
"""
list_display = ( ' title ' , ' emailto ' , ' send_result ' , ' creation_time ' )
readonly_fields = (
' title ' ,
' emailto ' ,
' send_result ' ,
' creation_time ' ,
' content ' )
def has_add_permission ( self , request ) :
"""
控制是否具有添加新记录的权限
重写父类方法,禁止用户在管理后台手动添加邮件发送日志记录
Args:
request: HTTP请求对象
Returns:
bool: 总是返回False, 表示没有添加权限
"""
return False