在users模块中添加adminx.py文件,是xadmin后台管理默认的文件名,内容是:
from .models import EmailVerifyRecord, Banner import xadmin class EmailVerifyRecordAdmin(object): list_display = (‘name‘, ‘email‘, ‘send_type‘, ‘add_time‘) search_fields = (‘name‘, ‘email‘, ‘send_type‘) list_filter = (‘name‘, ‘email‘, ‘send_type‘, ‘add_time‘) class BannerAdmin(object): list_display = (‘name‘, ‘image‘, ‘url‘, ‘order‘, ‘add_time‘) search_fields = (‘name‘, ‘image‘, ‘url‘, ‘order‘) list_filter = (‘name‘, ‘image‘, ‘url‘, ‘order‘, ‘add_time‘) xadmin.site.register(EmailVerifyRecord, EmailVerifyRecordAdmin) xadmin.site.register(Banner, BannerAdmin)
因为UserProfile是默认的用户表,系统和xadmin会自动处理用户表,所以不用添加,而只添加邮箱验证和轮播图。其中邮箱验证需要作修改:
class Meta: verbose_name = ‘邮箱验证码‘ verbose_name_plural = verbose_name def __str__(self): return ‘{0}({1})‘.format(self.name, self.email)
就是返回的不是name,而是name和email的组合。
原文地址:https://www.cnblogs.com/andu99/p/8985638.html
时间: 2024-11-09 02:45:33