[英]Custom Filter in Django (1.3) Admin
如何在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中,我必须为状态为“生产”的“县”字段的“ County_info”模型显示过滤器。
list_filter = ['county__name', ] # will Show all data in that table. I need onlt the data which has status= 'production'
我怎样才能做到这一点 ?
几天前我遇到了同样的问题,我发现只有使用1.4才可能: 管理员过滤器文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.