码迷,mamicode.com
首页 > 其他好文 > 详细

添加courses模块

时间:2018-05-02 19:08:13      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:pycha   gre   div   添加   cas   HERE   快捷   收藏   rbo   

startapp courses

 

from django.db import models
from datetime import datetime


# Create your models here.


class Course(models.Model):
    name = models.CharField(max_length=100, verbose_name=课程名)
    desc = models.CharField(max_length=300, verbose_name=课程描述)
    detail = models.TextField(verbose_name=课程详情)
    degree = models.CharField(max_length=10, verbose_name=课程难度, choices=((cj, 初级), (zj, 中级), (gj, 高级)))
    learn_time = models.IntegerField(default=0, verbose_name=学习时长(分钟))
    learn_nums = models.IntegerField(default=0, verbose_name=学习人数)
    fav_nums = models.IntegerField(default=0, verbose_name=收藏人数)
    image = models.ImageField(max_length=100, verbose_name=封面图, upload_to=static/uploads/courses/%Y/%m)
    click_nums = models.IntegerField(default=0, verbose_name=点击数)
    add_time = models.DateTimeField(default=datetime.now, verbose_name=创建时间)

    class Meta:
        verbose_name = 课程
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class Lesson(models.Model):
    course = models.ForeignKey(Course, on_delete=models.CASCADE, verbose_name=课程)
    name = models.CharField(max_length=100, verbose_name=章节名)
    add_time = models.DateTimeField(default=datetime.now, verbose_name=创建时间)

    class Meta:
        verbose_name = 章节
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class Video(models.Model):
    lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE, verbose_name=章节)
    name = models.CharField(max_length=100, verbose_name=章节名)
    add_time = models.DateTimeField(default=datetime.now, verbose_name=创建时间)

    class Meta:
        verbose_name = 视频
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class CourseResource(models.Model):
    course = models.ForeignKey(Course, on_delete=models.CASCADE, verbose_name=课程)
    name = models.CharField(max_length=100, verbose_name=资源名)
    download = models.FileField(max_length=100, verbose_name=上传文件, upload_to=static/uploads/courses/%Y/%m)
    add_time = models.DateTimeField(default=datetime.now, verbose_name=创建时间)

    class Meta:
        verbose_name = 课程资源
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

 

pycharm 使用vs快捷键,输完后 ctrl + alt + f 格式化代码

添加courses模块

标签:pycha   gre   div   添加   cas   HERE   快捷   收藏   rbo   

原文地址:https://www.cnblogs.com/andu99/p/8981590.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!