推荐学习书目
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
superbai
V2EX  ›  Python

django 如何在创建表的时候设置 charset 为 utf8

  •  
  •   superbai · Oct 17, 2019 · 4153 views
    This topic created in 2410 days ago, the information mentioned may be changed or developed.
    django2.2.6,通过 django 自带的 python manage.py migrate 命令建表之后,发现表的 charset 是 latin1,如何设置让 django 创建表的时候默认 charset 是 utf8 呢?
    6 replies    2019-10-19 19:08:52 +08:00
    janxin
        1
    janxin  
       Oct 17, 2019
    DATABASES 里面配置了吗
    superbai
        2
    superbai  
    OP
       Oct 17, 2019
    @janxin #1 是指 option 里面吗?
    elioti
        3
    elioti  
       Oct 17, 2019
    不是先去数据库里创建的时候 用 create database xxx charset=utf8;指明吗
    superbai
        4
    superbai  
    OP
       Oct 17, 2019
    @elioti #3 是的,最后用这种方法解决了。但是想知道 django 的 model 里有没有关于字符编码的设置项
    a852695
        5
    a852695  
       Oct 18, 2019
    django 可以设置 但是如果你 create db 时候不是 utf8 它也修改不鸟
    superbai
        6
    superbai  
    OP
       Oct 19, 2019
    @a852695 #5 在哪里设置?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   872 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 22:04 · PVG 06:04 · LAX 15:04 · JFK 18:04
    ♥ Do have faith in what you're doing.