推荐学习书目
› 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 · Apr 9, 2019 · 2701 views
    This topic created in 2732 days ago, the information mentioned may be changed or developed.

    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 了一大圈没有线索,还请有遇到过的大佬解惑,谢谢!

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   829 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 22:43 · PVG 06:43 · LAX 15:43 · JFK 18:43
    ♥ Do have faith in what you're doing.