如何在Django Admin中添加一个过滤器,该过滤器应该在模型仪表板右侧显示的过滤器中提供过滤结果。
更清楚:
class County (models.Model):
status = models.CharField(max_length = 255, blank = True)
name = models.CharField(max_length = 255, blank = True)
class County_info (models.Model):
county = models.ForeignKey(County)
city = models.CharField(max_length = 255, blank = True)
state = models.CharField(max_length = 255, blank = True)
......
......
在我的adim.py中,我必须为状态为“Production”的字段“county”显示模型“County_info”的过滤器。
list_filter = ['county__name', ] # will Show all data in that table. I need onlt the data which has status= 'production'
我该怎么做?