允许列表中的外键属性显示为“\uu”

django-related-admin的Python项目详细描述


https://travis-ci.org/PetrDlouhy/django-related-admin.svg?branch=masterhttps://coveralls.io/repos/github/PetrDlouhy/django-related-admin/badge.svg?branch=masterhttps://badge.fury.io/py/django-related-admin.svg

允许Django管理更改列表中的外键属性list_display使用'\uuu'

这是基于kpacn制作的DjangoSnippet 2996

安装

  1. 此库位于pypi上,因此您可以使用以下命令安装它:

    pip install django-related-admin
    

或来自github:

pip install git+https://github.com/PetrDlouhy/django-related-admin#egg=django-related-admin
  1. 将“相关管理员”添加到已安装的应用程序设置中,如下所示:

    INSTALLED_APPS = (
        ...
        'related_admin',
        'django.contrib.admin',
    )
    

注意:django相关的管理更改change_list.html模板以禁用white-space: nowrap; 管理头上的css类,以允许长(位置相关的)头名称换行。 如果您想要此行为,请在django.contrib.admin之前添加应用程序,否则在django.contrib.admin之后添加应用程序。

用法

只需使用它而不是model.admin:

from related_admin import RelatedFieldAdmin
from related_admin import getter_for_related_field

class FooAdmin(RelatedFieldAdmin):
    # these fields will work automatically (and boolean fields will display an icon):
    list_display = ('address__phone','address__country__country_code','address__foo')

    # ... but you can also define them manually if you need to override short_description or boolean parameter:
    address__foo = getter_for_related_field('address__foo', short_description='Custom Name', boolean=True)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Gson类中的java验证错误   If和elseif之间的java差异?   字典Java8地图。输入比较器   java连接到远程计算机以获得WMI支持   java如何使用改型处理JSON对象中的空值   在Java中使用Comparator时不可编译的源代码   java将Jar添加到JSP的运行时路径   带有随机对象的while循环的java大O时间复杂性   java可以在不考虑参数的情况下模拟方法吗?   java我有一个简单的代码,它不工作。无法修复错误“println”   向eclipse添加Xively java库   java是否可以启用本机代码的缓存?   全局变量如何在Java中的所有类之间共享要使用的语言环境?   Java内存游戏如何翻转单个卡?