This chapter is accompanied by video tutorials :Python-Django Develop personal blog from scratch _ Bili, Bili _bilibili
In the Blog websites we usually see , General blog will have classification , article , Article Tags , Article filing , Hot articles , The latest article , Links and other basic functions , So let's learn the data model for setting up these functions .
class Category(models.Model):
""" Classification model of Blog """
name = models.CharField(max_length=32, verbose_name=" Category name ")
desc = models.TextField(max_length=200, blank=True, default='', verbose_name=" Classification description ")
add_date = models.DateTimeField(auto_now_add=True, verbose_name=" Add the time ")
pub_date = models.DateTimeField(auto_now=True, verbose_name=" Modification time ")
class Meta:
verbose_name = " Blog classification "
verbose_name_plural = verb