django raw_id_fields 显示名称而不是id(raw_id_fields: How to show a name instead of id)
为了防止页面加载的时候加载所有的Foreignkey到内存,django提供了一个raw_id_fields,该tupple内的数据将只展示id。虽然内存不加载了,但是基本没法看。不知道是个什么东西。
这尼玛tags和Porn model完全看不出是个什么东西。如果要展示相关的名称可以使用django-dynamic-raw-id:
A Django admin raw_id_fields widget replacement that handles display of an object’s string value on change and can be overridden via a template
使用方法: https://pypi.org/project/django-dynamic-raw-id/
具体效果:
嗯,非常直观~ 测试环境:python 3.7.2 + django 3.7.2
settings.py中关闭debug之后可能会出现上面的情况,没有显示名称,执行一下python manage.py collectstatic即可。
☆文章版权声明☆
* 网站名称:obaby@mars * 网址:https://h4ck.org.cn/ * 本文标题: 《django raw_id_fields 显示名称而不是id(raw_id_fields: How to show a name instead of id)》 * 本文链接:https://h4ck.org.cn/2020/06/django-raw_id_fields-%e6%98%be%e7%a4%ba%e5%90%8d%e7%a7%b0%e8%80%8c%e4%b8%8d%e6%98%afid%ef%bc%88raw_id_fields-how-to-show-a-name-instead-of-id%ef%bc%89/ * 转载文章请标明文章来源,原文标题以及原文链接。请遵从 《署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5 CN) 》许可协议。
分享文章:
相关文章:
- Django 限制访问频率
- 再谈《Django 限制访问频率》
- Django input value值被截断
- Django APScheduler + uwsgi 定时任务重复运行
- Django REST framework foreignkey 序列化
- Django admin Foreignkey ManyToMany list_display展示
- django 主动抛出 403 异常
- ngix+uwsgi+django 以及阿里云rds数据库数据导入
- ubuntu uwsgi No module named ‘django’
- Apache2 Django {“detail”:”Authentication credentials were not provided.”}
相关文章
- pycharm django环境搭建_IDEA如何创建项目
- 部署上线-部署Django项目
- Django(55)GenericAPIView源码分析
- Django(21)migrate报错的解决方案
- django官方入门教程_DJango
- 【Django】在大型项目中的django的性能模型字段primary_key
- To add browser notifications to an online customer support live chat service system - gofly - self h
- windows +apache + django + mod_wsgi 部署 Django 站点
- Add a button/form/link to Django Admin(添加按钮、表单、链接到 django admin)
- django admin 给 字段 增加 HTML 样式(显示图片、设置字体颜色、超链接、按钮等)
- django admin 只有两种状态非布尔类型的字段转成布尔类型,admin 后台显示 绿色勾 和 红色叉
- 'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEWARE in order to use the
- django的CMS系统(内容管理系统)详解大数据
- python3开发进阶-Django框架的中间件的五种用法和逻辑过程详解编程语言
- Django简介详解编程语言
- eclipse pydev django 接收 post 发来的 json 请求详解编程语言
- Python3:Django连接Mysql数据库时出错,’Did you install mysqlclient or MySQL-python’详解编程语言
- 服务器上部署django项目流程详解编程语言
- ECC TO HANA FAGLB03 search-help on Account Number field doesn’t working or not returning the selected value to the Account Number field.详解编程语言
- Django基础学习七之如何配置django+mysql详解编程语言
- Django基础学习二详解编程语言
- 利用Oracle TO函数实现数据转换(oracle to_函数)