Skip to content

Commit

Permalink
Merge pull request #119 from liangliangyy/dev
Browse files Browse the repository at this point in the history
增加文章排序
  • Loading branch information
liangliangyy authored May 19, 2018
2 parents e211b3b + f5c292a commit 82505ed
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions DjangoBlog/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ class DjangoBlogFeed(Feed):
feed_type = Rss201rev2Feed

description = '大巧无工,重剑无锋.'
feed_url = 'https://www.lylinux.net/feed'
title = "且听风吟 大巧无工,重剑无锋. "
link = "https://www.lylinux.net"
link = "/feed/"

def author_name(self):
return get_user_model().objects.first().nickname
Expand Down
2 changes: 1 addition & 1 deletion blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def open_article_commentstatus(modeladmin, request, queryset):
class ArticlelAdmin(admin.ModelAdmin):
search_fields = ('body',)
form = ArticleForm
list_display = ('id', 'title', 'author', 'created_time', 'views', 'status', 'type')
list_display = ('id', 'title', 'author', 'created_time', 'views', 'status', 'type','article_order')
list_display_links = ('id', 'title')
list_filter = (ArticleListFilter, 'status', 'type', 'category', 'tags')
filter_horizontal = ('tags',)
Expand Down
4 changes: 2 additions & 2 deletions blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ class Article(BaseModel):
type = models.CharField('类型', max_length=1, choices=TYPE, default='a')
views = models.PositiveIntegerField('浏览量', default=0)
author = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='作者', on_delete=models.CASCADE)

article_order = models.IntegerField('排序,数字越大越靠前', blank=False, null=False, default=0)
category = models.ForeignKey('Category', verbose_name='分类', on_delete=models.CASCADE, blank=False, null=False)
tags = models.ManyToManyField('Tag', verbose_name='标签集合', blank=True)

def __str__(self):
return self.title

class Meta:
ordering = ['-pub_time']
ordering = ['-article_order', '-pub_time']
verbose_name = "文章"
verbose_name_plural = verbose_name
get_latest_by = 'created_time'
Expand Down

0 comments on commit 82505ed

Please sign in to comment.