用户表中添加邮箱验证码数据表,轮播图数据表

from django.db import models
from django.contrib.auth.models import AbstractUser
from datetime import datetime

# Create your models here.

class UserProfile(AbstractUser):
    nick_name = models.CharField(max_length=50, verbose_name='昵称', default='')
    birthday = models.DateField(verbose_name='生日', null=True, blank=True)
    gender = models.CharField(max_length=10, choices=(('male', '男'), ('female', '女')), verbose_name='性别',
                              default='female')
    address = models.CharField(max_length=100, default='')
    mobile = models.CharField(max_length=11, verbose_name='手机号码', null=True, blank=True)
    image = models.ImageField(max_length=100, verbose_name='用户头像', upload_to='static/uploads/images/%Y/%m',
                              default='static/uploads/images/default.jpg')

    class Meta:
        verbose_name = '用户信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username

class EmailVerifyrecord(models.Model):
    name = models.CharField(max_length=20, verbose_name='验证码')
    email = models.EmailField(max_length=50, verbose_name='邮箱')
    send_type = models.CharField(max_length=10, choices=(('register', '注册'), ('forget', '找回密码')), verbose_name='验证码类型')
    add_time = models.DateTimeField(default=datetime.now, verbose_name='创建时间')

    class Meta:
        verbose_name = '邮箱验证码'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

class Banner(models.Model):
    name = models.CharField(max_length=100, verbose_name='标题')
    image = models.ImageField(max_length=100, verbose_name='轮播图片', upload_to='static/uploads/banners/%Y/%m')
    url = models.URLField(max_length=200, verbose_name='访问链接')
    order = models.IntegerField(default=100, verbose_name='轮播顺序')
    add_time = models.DateTimeField(default=datetime.now, verbose_name='创建时间')

    class Meta:
        verbose_name = '轮播图'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
    def __str__(self):
        return self.name

这个是在xadmin后台管理中,添加数据的时候,显示添加 users.轮播图,而不是users.objects(1)

05-11 22:39