zoukankan      html  css  js  c++  java
  • 实验楼表关系建立 (课程模块·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
    

      

  • 相关阅读:
    2
    1
    Java面试题整理二(侧重SSH框架)
    solr添加多个core
    Oracle SQL性能优化
    jQuery的$.ajax
    spring四种依赖注入方式
    通过JAXB完成Java对象与XML之间的转换
    window环境下将solr6.3部署到tomcat中
    Java面试题整理一(侧重多线程并发)
  • 原文地址:https://www.cnblogs.com/zhangshijiezsj/p/13806578.html
Copyright © 2011-2022 走看看