- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在我的 admin.py 中,我按“事件”和“国家/地区”进行过滤,这是使用我的 SomethingAdmin 类中的以下代码行完成的....
list_filter = ['active', 'countryid']
如您所见,countryid 在我的管理 ListView 中显示时并不漂亮,我如何才能将其更改为更友好的名称,比如只说“国家/地区”?
谢谢。
更新:以下似乎有效:
incentiveid = models.ForeignKey(Incentive,verbose_name="Incentive",
null=True, db_column='incentiveID', blank=True)
最佳答案
作为Aamir说,如果您在模型中的字段上定义标签,您应该会看到更有吸引力的过滤器选项:
class MyModel(models.Model):
countryid = models.ForeignKey(Country,
verbose_name="Country", null=True,
db_column='countryID', blank=True)
假设 Country
是另一个 Model
的名称 - 这应该显示在 Admin
过滤器 View 中。
关于python - Django:使用友好名称的 list_filter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14707226/
您好,我有两个对象: class A(models.Model): ... class B(models.Model): a = models.ForeignKey(A) 在管理员中,
Django 不支持从 list_display 或 list_filter 获取外键值(例如 foo__bar)。我知道您可以创建一个模块方法作为 list_display 的解决方法,但是我将如何
DECOM_CHOICES = ( ('N', 'No'), ('Y', 'Yes'), ) class Host(models.Model): hostname = mode
我正尝试在 Django Admin 中过滤带注释的字段,但出现 FieldDoesNotExist 错误。 class Event(models.Model): name = models.
让我们看一下这个例子: class Author(models.Model): ... class Book(models.Model): author = models.For
我用额外的选项扩展了用户,比如部门。但是当我尝试在管理面板为 derpartment 添加过滤器时。它抛出这个错误: ERRORS: : (admin.E116) The value of 'list
鉴于以下模型 class AnotherModel(models.Model): n = models.IntegerField() class MyModel(models.Model):
我的模型的change_list View 如下所示: 右侧的list_filter变得太长并且无法使用。 有没有办法获得更有用的方式来过滤Django的change_list View ? 最佳答案
我正在开发一个同时具有管理员和子管理员的应用程序。子管理员是根据他们所属的组创建的。因此,子管理员只能看到与其组相关的数据。此功能运行完美。 现在,我想创建一个基于用户的过滤器选项。对于 super
我们有三个模型,艺术家: class Artist(models.Model): family_name = models.CharField(max_length=50) given
在我的 admin.py 中,我按“事件”和“国家/地区”进行过滤,这是使用我的 SomethingAdmin 类中的以下代码行完成的.... list_filter = ['active', 'c
在 models.py 中我有: class User(modals.Model): name = models.CharField(max_length=255) image = m
如何根据登录用户在右侧list_filter中显示不同的记录? eg 如果superuser登陆listfilter可以查看list_filter中branch的changelist_view中所有客
所以这是我的代码: class Destino(models.Model): paisid = models.IntegerField(blank = True,null = True)
很抱歉,如果这个问题之前已经回答过,但我做了很多谷歌搜索都没有成功。 我知道如何在管理 View 中创建自定义 list_filter(例如子类化 SimpleFilter)。 我真正想要的是一种(在
我有一个模型,其字段如图所示。我在 wagtail_hooks.py 中创建了以下 ModelAdmin。 class opportunitiesAdmin(ModelAdmin): mode
是否可以只为 super 用户显示 list_filter? 最佳答案 Override changelist view 存储原始列表过滤器的副本,以便您可以根据请求动态设置属性。检查用户是否为 su
我想覆盖默认的 django 管理过滤器模板以使用我自己的模板: https://github.com/feincms/feincms/blob/master/feincms/templates/ad
django admin 中外键过滤器的 List_filter 标签始终按 id 排序,当列表中有很多过滤器时,这可能会导致困惑。 一段时间以来,我一直在寻找简单的解决方案,如何按字母顺序或按日期对
我需要按字段进行一对多过滤,但我只想显示相关对象而不是全部。 这可能吗,还是我必须创建自定义过滤器? 最佳答案 我尽量让我的模板保持“愚蠢”,所以我肯定会在 View 中过滤我的数据。你可以尝试这样的
我是一名优秀的程序员,十分优秀!