6

在我的 admin.py 中,我按“活动”和“国家”进行过滤,这是使用SomethingAdmin 类中的以下代码行完成的......

 list_filter = ['active', 'countryid']

正如您所见,countryid 在我的管理列表视图中显示时并不漂亮,我怎样才能将其更改为更友好的名称,只说“国家”?

谢谢。

更新: 下面似乎工作:

incentiveid = models.ForeignKey(Incentive,verbose_name="Incentive", 
null=True, db_column='incentiveID', blank=True)
4

1 回答 1

5

正如Aamir所说,如果您在模型中的字段上定义标签,您应该会看到更具吸引力的过滤器选项:

class MyModel(models.Model):
    countryid = models.ForeignKey(Country, 
                                  verbose_name="Country", null=True, 
                                  db_column='countryID', blank=True)

假设这Country是另一个名称Model- 这应该显示在Admin过滤器视图中。

于 2013-02-05T12:16:25.623 回答