慕学在线网0.2_users表设计(2)

接着上一篇,我们继续对users表进行完善。其中包括邮箱验证码(EmailVerifyRecord)和轮播图(PageBanner)两个model。

  
1、编写“models.py”:

from datetime import datetime


class EmailVerifyRecord(models.Model):
    code = models.CharField(max_length=20, verbose_name="验证码")
    email = models.EmailField(max_length=50, verbose_name="邮箱")
    send_type = models.CharField(choices=(("register", "注册"), ("forget", "找回密码")), max_length=10)
    send_time = models.DateTimeField(default=datetime.now)  # 需要把now后面的括号去掉

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


class Banner(models.Model):
    title = models.CharField(max_length=100, verbose_name="标题")
    image = models.ImageField(upload_to="banner/%Y/%m", verbose_name="轮播图", max_length=100)
    url = models.URLField(max_length=200, verbose_name="访问地址")
    index = models.IntegerField(default=100, verbose_name="顺序")
    add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间")

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

2、设计完成后,我们可以通过pycharm左边的structure查看当前model
慕学在线网0.2_users表设计(2)_第1张图片
  
未完待续~~~

转载于:https://www.cnblogs.com/WoLykos/p/9639539.html

你可能感兴趣的:(慕学在线网0.2_users表设计(2))