0

如何在 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 中,我必须为状态为“生产”的字段“县”显示模型“县信息”的过滤器。

list_filter = ['county__name', ] # will Show all data in that table. I need onlt the data which has status= 'production'

我怎样才能做到这一点 ?

4

1 回答 1

0

几天前我遇到了同样的问题,我发现只有使用 1.4 才有可能:Admin filter documentation

于 2012-11-15T18:06:36.730 回答