2012-11-15 47 views
0

如何在Django Admin中添加一個過濾器,該過濾器應該在模型儀表板右側顯示的過濾器中給出過濾結果。Django中的自定義過濾器(1.3)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' 

我該怎麼做?

回答