程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

(14) Django creates a blog data model

編輯:Python

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 .

Create a blog classification model Category

  • stay blog/models.py Create a classification data model in Category
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

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved