0
我的管理頁面中有'網站'部分。這裏是我的models.py的一部分:Django - 來自同一模型的兩個部分
class Site(models.Model):
category = models.ForeignKey('Category')
subcategory = ChainedForeignKey(
'Subcategory',
chained_field='category',
chained_model_field='category',
show_all=False,
auto_choose=True)
name = models.CharField(max_length=70)
description = models.TextField()
keywords = MyTextField()
date = models.DateTimeField(default=datetime.now, editable=False)
url = models.URLField()
is_active = models.BooleanField(default=False)
我想補充另一個站點一節中我的管理,這將只顯示活動的站點(IS_ACTIVE = FALSE)。可能嗎? (我的意思是:
Sites - first section (list of all sites)
Inactive sites (number of inactive sites) - second section (only inactive sites)
)
這裏是我的管理類:
class SiteAdmin(admin.ModelAdmin):
list_display = ('is_active', 'name', 'description', 'keywords', 'date')
fields = ('name', 'url', 'category', 'subcategory', 'description',
'keywords', 'date', 'is_active')
readonly_fields = ('date',)
list_editable = ('is_active',)
list_display_links = ('name',)