text: from django.db import models
  from django.utils import timezone
  
  from django.db.models import Model, CharField, DateTimeField, IntegerField, DateField, ImageField, EmailField, URLField
  from django.contrib.auth.models import AbstractUser
  
  # Create your models here.
  
  
  class UserProfile(AbstractUser):
      nick_name = CharField(max_length=50, verbose_name='昵称')
      birthday = DateField(verbose_name='生日', null=True, blank=True)
      gender = CharField(max_length=10, choices=(('male', '男'), ('female', '女')),verbose_name='性别')
      address = CharField(max_length=255, default='', verbose_name='住址')
      mobile = CharField(max_length=11, verbose_name='手机')
      image = ImageField(upload_to='image/%Y/%m', default='image/default.jpg', verbose_name='头像')
  
      class Meta:
          verbose_name = '用户信息'
          verbose_name_plural = verbose_name
  
      def get_unread_msg_num(self):
          from operation.models import UserMessage
          return UserMessage.objects.filter(user=self.id, has_read=False).count()
  
      def __unicode__(self):
          return self.username
  
  
  class EmailVerifyRecord(Model):
      code = CharField(max_length=20, verbose_name='验证码')
      email = EmailField(max_length=50, verbose_name='邮箱')
      send_type = CharField(max_length=16, choices=(('register', '注册'), ('forget', '找回密码'), ('update_email', '重置邮箱')), verbose_name='验证码类型')
      send_time = DateTimeField(default=timezone.now, verbose_name='发送时间')
  
      class Meta:
          verbose_name = '邮箱验证'
          verbose_name_plural = verbose_name
  
  
  class Banner(Model):
      title = CharField(max_length=100, verbose_name='标题')
      image = ImageField(upload_to='banner/%Y/%m', verbose_name='轮播图')
      url = URLField(max_length=200, verbose_name='访问地址')
      index = IntegerField(default=100, verbose_name='顺序')
      add_time = DateTimeField(default=timezone.now, verbose_name='添加时间')
  
      class Meta:
          verbose_name = '轮播图'
          verbose_name_plural = verbose_name
  