首页 Django项目开发与部署视频教程 完善数据表和字段,迁移数据库
pay pay

完善数据表和字段,迁移数据库

日期: 六月 25, 2023, 9:48 a.m.
阅读: 78
作者: Python自学网-村长

摘要: 完善数据表和字段,迁移数据库

完善数据表和字段,迁移数据库

from django.db import models
from ckeditor_uploader.fields import RichTextUploadingField


class Art_List(models.Model):
    art_list_title = models.CharField(max_length=200, verbose_name='标题')
    art_list_short_title = models.CharField(max_length=80, verbose_name='副标题')
    art_list_keyword = models.CharField(max_length=200, blank=True, verbose_name='关键词')
    art_list_description = models.CharField(max_length=254, blank=True, verbose_name='描述')
    art_list_tail = models.CharField(max_length=80, verbose_name='网址后缀', unique=True)
    art_list_click = models.IntegerField(default=1, verbose_name='点击数')
    art_list_img = models.ImageField(upload_to='', verbose_name='缩略图', default='default_img.jpg')
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.art_list_title

    class Meta:
        db_table = 'article_list'
        ordering = ['-id']
        verbose_name = '文章列表'
        verbose_name_plural = verbose_name


class Art(models.Model):
    """title/short_title/keyword/description/text/click/del/tail/time/tag/img/top_list/author/recommend/top"""
    art_title = models.CharField(max_length=200, verbose_name='文章标题')
    art_short_title = models.CharField(max_length=200, verbose_name='文章副标题', blank=True)
    art_keyword = models.CharField(max_length=60, verbose_name='文章关键词', blank=True)
    art_description = models.CharField(max_length=254, verbose_name='文章描述', blank=True)
    art_text = RichTextUploadingField(verbose_name='文章正文')
    art_click = models.IntegerField(default=0, verbose_name='点击数')
    art_tail = models.CharField(max_length=60, verbose_name='网址后缀')
    art_time = models.DateTimeField(auto_now_add=True, verbose_name='发布时间')
    art_tag = models.ManyToManyField(to='Tags', blank=True, verbose_name='标签')
    art_img = models.ImageField(upload_to='', blank=True, null=True, verbose_name='图片上传')
    art_top_list = models.ForeignKey(to=Art_List, verbose_name='所属列表', on_delete=models.DO_NOTHING)
    art_author = models.CharField(max_length=60, verbose_name='作者')
    art_recommend = models.BooleanField(default=False, verbose_name='推荐')
    art_top = models.BooleanField(default=False, verbose_name='置顶')
    art_del = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.art_title

    class Meta:
        db_table = 'article'
        ordering = ['-id']
        verbose_name = '文章'
        verbose_name_plural = verbose_name


class Download_List(models.Model):
    down_col_title = models.CharField(max_length=200, verbose_name='标题')
    down_col_short_title = models.CharField(max_length=80, verbose_name='副标题', blank=True)
    down_col_keyword = models.CharField(default='', max_length=200, blank=True, verbose_name='关键词')
    down_col_description = RichTextUploadingField(default='', blank=True, verbose_name='描述')
    down_col_click = models.IntegerField(default=1, verbose_name='点击数')
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.down_col_title

    class Meta:
        db_table = 'download_list'
        ordering = ['-id']
        verbose_name = '下载列表'
        verbose_name_plural = verbose_name


class Download(models.Model):
    down_title = models.CharField(max_length=200, verbose_name='标题')
    down_short_title = models.CharField(max_length=200, blank=True, verbose_name='副标题')
    down_keyword = models.CharField(max_length=80, blank=True, verbose_name='关键词')
    down_description = models.CharField(max_length=255, blank=True, verbose_name='描述')
    down_text = RichTextUploadingField(verbose_name='正文')
    down_tail = models.CharField(max_length=80, verbose_name='网址后缀', unique=True)
    down_click = models.IntegerField(default=1, verbose_name='点击数')
    down_time = models.DateTimeField(auto_now=True, verbose_name='更新时间')
    down_img = models.ImageField(upload_to='', verbose_name='缩略图', default='default_img.jpg')
    down_ico = models.ImageField(upload_to='', verbose_name='小图标', default='ico_img.jpg')
    down_limit = models.BooleanField(default=False, verbose_name='下载权限')
    down_order = models.IntegerField(default=0, verbose_name='排序')
    down_class = models.CharField(max_length=120, verbose_name='下载分类', blank=True)
    # 软件信息
    soft_name = models.CharField(max_length=100, verbose_name='软件名称', blank=True)
    soft_kb = models.CharField(max_length=100, verbose_name='软件大小', blank=True)
    soft_link = models.CharField(max_length=255, verbose_name='下载链接', blank=True)
    soft_http = models.CharField(max_length=255, verbose_name='官网地址', blank=True)
    soft_edition = models.CharField(max_length=100, verbose_name='软件版本', blank=True)
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.down_title

    class Meta:
        db_table = 'download'
        ordering = ['-id']
        verbose_name = '下载页面'
        verbose_name_plural = verbose_name


class Video_List(models.Model):
    video_list_title = models.CharField(max_length=200, verbose_name='标题')
    video_list_short_title = models.CharField(max_length=80, verbose_name='副标题', blank=True)
    video_list_keyword = models.CharField(max_length=200, blank=True, verbose_name='关键词')
    video_list_description = RichTextUploadingField(default='', blank=True, verbose_name='描述')
    video_list_order = models.IntegerField(default=0, verbose_name='排序')
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.video_list_title

    class Meta:
        db_table = 'video_list'
        ordering = ['-id']
        verbose_name = '视频列表'
        verbose_name_plural = verbose_name


class Video(models.Model):
    video_title = models.CharField(max_length=200, verbose_name='标题')
    video_short_title = models.CharField(max_length=200, blank=True, verbose_name='副标题')
    video_keyword = models.CharField(max_length=200, blank=True, verbose_name='关键词')
    video_description = models.CharField(max_length=240, blank=True, verbose_name='描述')
    video_order = models.IntegerField(default=0, verbose_name='视频排序')
    video_text = RichTextUploadingField(verbose_name='正文')
    video_author = models.CharField(max_length=50, verbose_name='作者', default='Python自学网-村长')
    video_tail = models.CharField(max_length=80, verbose_name='网址后缀', unique=True)
    video_click = models.IntegerField(default=1, verbose_name='点击数')
    video_time = models.DateTimeField(auto_now_add=True, verbose_name='发布时间')
    video_link = models.CharField(max_length=255, verbose_name='短视频链接', default='')
    video_vip_link = models.CharField(max_length=255, verbose_name='长视频连接', default='')
    video_long = models.IntegerField(default=3, verbose_name='视频时长')
    video_img = models.ImageField(upload_to='', blank=True, null=True, verbose_name='缩略图', default='default_img.jpg')
    video_top_list = models.ForeignKey(to=Video_List, verbose_name='所属章节', on_delete=models.DO_NOTHING)
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.video_title

    class Meta:
        db_table = 'video'
        ordering = ['-id']
        verbose_name = '视频内容'
        verbose_name_plural = verbose_name


class User(models.Model):
    user_name = models.CharField(max_length=50, verbose_name='用户名', unique=True)
    user_password = models.CharField(max_length=255, verbose_name='密码')
    user_tel = models.CharField(max_length=33, verbose_name='手机号', unique=True)
    user_mail = models.CharField(max_length=200, verbose_name='邮箱', unique=True)
    is_activate = models.BooleanField(default=False, verbose_name='激活')
    vip_statu = models.BooleanField(verbose_name='会员-1', default=False)
    user_register_time = models.DateTimeField(auto_now_add=True, verbose_name='注册时间', blank=True, null=True)
    user_vip_time = models.DateTimeField(auto_now=True, verbose_name='充值时间', blank=True, null=True)
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.user_name

    class Meta:
        db_table = 'user'
        ordering = ['-id']
        verbose_name = '用户表'
        verbose_name_plural = verbose_name


class Tags(models.Model):
    tag_title = models.CharField(max_length=200, verbose_name='标题')
    tag_short_title = models.CharField(max_length=200, verbose_name='副标题', blank=True)
    tag_keyword = models.CharField(max_length=60, verbose_name='关键词', blank=True)
    tag_description = models.CharField(max_length=254, default='', verbose_name='描述', blank=True)
    tag_tail = models.CharField(max_length=80, verbose_name='网址后缀', unique=True)
    tag_click = models.IntegerField(default=0, verbose_name='点击数')
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.tag_title

    class Meta:
        db_table = 'tags'
        ordering = ['-id']
        verbose_name = '标签'
        verbose_name_plural = verbose_name


class Page(models.Model):
    """title/keyword/description/text/click/del/tail"""
    page_title = models.CharField(max_length=200, verbose_name='标题')
    page_keyword = models.CharField(max_length=200, verbose_name='关键词', blank=True)
    page_description = models.CharField(max_length=240, verbose_name='描述', blank=True)
    page_text = RichTextUploadingField(verbose_name='正文')
    page_tail = models.CharField(max_length=80, verbose_name='网址后缀', unique=True)
    page_click = models.IntegerField(default=0, verbose_name='点击数')
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.page_title

    class Meta:
        db_table = 'page'
        ordering = ['-id']
        verbose_name = 'page页面'
        verbose_name_plural = verbose_name

 

原创视频,版权所有,未经允许,切勿转载,违者必究!
回顶部