@@ -15,20 +15,24 @@ class Article(models.Model):
1515 ('o' , '打开' ),
1616 ('c' , '关闭' ),
1717 )
18+ TYPE = (
19+ ('a' , '文章' ),
20+ ('p' , '页面' ),
21+ )
1822 title = models .CharField ('标题' , max_length = 200 )
1923 body = models .TextField ('正文' )
2024 created_time = models .DateTimeField ('创建时间' , auto_now_add = True )
2125 last_mod_time = models .DateTimeField ('修改时间' , auto_now = True )
2226 pub_time = models .DateTimeField ('发布时间' , blank = True , null = True ,
2327 help_text = "不指定发布时间则视为草稿,可以指定未来时间,到时将自动发布。" )
24- status = models .CharField ('文章状态' , max_length = 1 , choices = STATUS_CHOICES , default = 'o ' )
25- comment_status = models .CharField ('评论状态' , max_length = 1 , choices = COMMENT_STATUS )
26- # summary = models.CharField('摘要 ', max_length=200, blank=True, help_text="可选,若为空将摘取正文的前300个字符。" )
28+ status = models .CharField ('文章状态' , max_length = 1 , choices = STATUS_CHOICES , default = 'p ' )
29+ comment_status = models .CharField ('评论状态' , max_length = 1 , choices = COMMENT_STATUS , default = 'o' )
30+ type = models .CharField ('类型 ' , max_length = 1 , choices = TYPE , default = 'a' )
2731 views = models .PositiveIntegerField ('浏览量' , default = 0 )
2832 author = models .ForeignKey (settings .AUTH_USER_MODEL , verbose_name = '作者' , on_delete = models .CASCADE )
2933
30- category = models .ForeignKey ('Category' , verbose_name = '分类' , on_delete = models .CASCADE )
31- tags = models .ManyToManyField ('Tag' , verbose_name = '标签集合' , blank = True )
34+ category = models .ForeignKey ('Category' , verbose_name = '分类' , on_delete = models .CASCADE , blank = True , null = True )
35+ tags = models .ManyToManyField ('Tag' , verbose_name = '标签集合' , blank = True , null = True )
3236
3337 slug = models .SlugField (default = 'no-slug' , max_length = 60 , blank = True )
3438 wordpress_id = models .IntegerField ()
@@ -80,6 +84,7 @@ def comment_list(self):
8084 parent_comments = comments .filter (parent_comment = None )
8185
8286
87+ '''
8388class BlogPage(models.Model):
8489 """文章"""
8590 STATUS_CHOICES = (
@@ -113,7 +118,6 @@ def __str__(self):
113118 return self.title
114119
115120 def get_absolute_url(self):
116-
117121 return reverse('blog:pagedetail', kwargs=
118122 {
119123 'page_id': self.id,
@@ -139,6 +143,10 @@ def comment_list(self):
139143 comments = self.comment_set.all()
140144 parent_comments = comments.filter(parent_comment=None)
141145
146+ def get_category_tree(self):
147+ return []
148+ '''
149+
142150
143151class Category (models .Model ):
144152 """文章分类"""
0 commit comments