django 模板层排序 class Meta 添加信息



class weeks(models.Model):
    #星期信息
    stu = models.ForeignKey(students,on_delete=models.CASCADE)
    weeklist = ((1,'星期一'),(2,'星期二'),(3,'星期三'),(4,'星期四'),(5,'星期五'),(6,'星期六'),(7,'星期日'))
    week = models.PositiveSmallIntegerField(choices=weeklist,)
    #上课时间
    schooltime = models.TimeField(null=True,blank=True,verbose_name='上课时间')
    def __str__(self):
        return '%s %s %s'%(self.stu.name,self.get_week_display(),self.schooltime)
    class Meta:
        verbose_name = '星期 上课时间'
        ordering=['stu','week']

链接:

posted @ 2018-12-11 13:36 MAU 阅读(...) 评论(...) 编辑 收藏
Life will always knock us down, but we can choose whether to stand back up, then keep fighting. 生活会把我们打趴下,但我们可以选择重新站起来,继续奋斗。