我创建model必加的字段
class Category(models.Model):
pub_date = models.DateTimeField('发布日期',auto_now_add=True)
update_date = models.DateTimeField('更新日期',auto_now=True)
sort = models.IntegerField("序号",default=99,help_text="序号越小越靠前")
def __unicode__(self):
return self.title
def __str__(self):
return self.title
class Meta:
verbose_name = '目录'
verbose_name_plural = '0-目录'
ordering = ['sort'] # 按照哪个栏目排序
get_latest_by = 'pub_date'