V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
tomkliyes
V2EX  ›  Python

Django2.0 新增的 ModelAdmin.autocomplete_fields 功能 i18n 无效

  •  
  •   tomkliyes · 2019-04-09 15:55:34 +08:00 · 1542 次点击
    这是一个创建于 1838 天前的主题,其中的信息可能已经有所发展或是发生改变。

    django2.0 在 admin 中原生支持了 select2 实现的autocomplete_fields,用于 fk/m2m 关联关系中的异步搜索选择,十分好用,但始终没有办法切换中文,效果如下: 图片

    查看源码(django/contrib/admin/widgets.py,L444 )得知,在admin/js/vendor/select2/i18n/下有各个语言的 js 文件,根据 settings 设置的LANGUAGE_CODE自动选择加载对应语言的 js 文件,打开浏览器调试界面查看页面请求,发现确实请求了admin/js/vendor/select2/i18n/zh-CN.js文件,但依旧无法显示中文。

    Google 了一大圈没有线索,还请有遇到过的大佬解惑,谢谢!

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2622 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 10:43 · PVG 18:43 · LAX 03:43 · JFK 06:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.