• 实验楼表关系建立 (课程模块·5张表)


    实验楼表关系图

    from utils.MyBaseModel import Base
    from django.db import models
    #
    
    # Create your models here.
    # 课程类别
    class CourseType(Base):
        title = models.CharField('课程类别', max_length=32)
        sequence = models.IntegerField('顺序显示', default=10)
    
        class Meta:
            db_table = 'tb_coursetype'
    
        def __str__(self):
            return self.title
    
    #
    #课程标签
    class CourseTag(Base):
        title = models.CharField('课程标签', max_length=32)
        sequence = models.IntegerField('展示顺序', default=10)
    
        class Meta:
            db_table = 'tb_coursetag'
    
        def __str__(self):
            return self.title
    
    # 课程表
    class Course(Base):
        STATUS = (
            ('0', '即将上线'),
            ('1', '已上线'),
            ('2', '已下线'),
        )
        title = models.CharField('课程名', max_length=24)
        desc = models.CharField('课程名', max_length=256)
        img = models.ImageField('课程logo', upload_to='course', null=True)
        course_type = models.ForeignKey(CourseType, verbose_name='课程类别', on_delete=models.CASCADE, default=None, null=True)
        course_tag = models.ManyToManyField(CourseTag, verbose_name='课程标签')
        status = models.CharField('课程状态', choices=STATUS, max_length=8, default='1')
        attention = models.IntegerField('关注人数', default=0)
        learner = models.IntegerField('学习人数', default=0)
    
        class Meta:
            db_table = 'tb_course'
    
        def __str__(self):
            return self.title
    
    # zhang
    class Chapters(Base):
        title = models.CharField('章标题', max_length=24)
        serial_num=models.IntegerField('章序号')
        course=models.ForeignKey(Course,related_name='chapters',on_delete=models.SET_NULL,null=True)
    
        class Meta:
            db_table = 'tb_chapters'
    
        def __str__(self):
            return self.title
    # 节表
    class Sections(Base):
        title = models.CharField('节标题', max_length=32)
        serial_num=models.IntegerField('节序号')
        chapters=models.ForeignKey(Chapters,related_name='sections',on_delete=models.SET_NULL,null=True)
        learn_time=models.IntegerField('学习小时',default=1)
        video=models.FileField('上传视频',upload_to='videos/%Y%m%d/',blank=True,max_length=1024)
        seq_num = models.IntegerField('序号', default=1)
    
        class Meta:
            db_table = 'tb_sections'
        def __str__(self):
            return self.title
    

      

  • 相关阅读:
    如何检测死锁并快速定位死锁位置
    几种线程本地存储变量和普通变量的性能比较
    multi_index_container性能测试
    [高并发引擎]定时器模块
    [高并发引擎]Log模块
    静态博客教程 1:hexo + github
    蛇形填数
    实现简单的 ls 命令
    静态库与动态库的创建和使用
    用两个栈实现队列
  • 原文地址:https://www.cnblogs.com/zhangshijiezsj/p/13806578.html
Copyright © 2020-2023  润新知