Skip to content

Commit 4299f19

Browse files
authored
Merge pull request #504 from laozijiaojiangnan/feat-sort-category
feat(admin):实现分类顺序控制功能
2 parents 4928052 + d36a4ff commit 4299f19

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

blog/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class TagAdmin(admin.ModelAdmin):
111111

112112

113113
class CategoryAdmin(admin.ModelAdmin):
114+
list_display = ('name', 'parent_category', 'index')
114115
exclude = ('slug', 'last_mod_time', 'created_time')
115116

116117

blog/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,10 @@ class Category(BaseModel):
174174
null=True,
175175
on_delete=models.CASCADE)
176176
slug = models.SlugField(default='no-slug', max_length=60, blank=True)
177+
index = models.IntegerField(default=0, verbose_name="权重排序-越大越靠前")
177178

178179
class Meta:
179-
ordering = ['name']
180+
ordering = ['-index']
180181
verbose_name = "分类"
181182
verbose_name_plural = verbose_name
182183

0 commit comments

Comments
 (0)