How to set the encoding for the tables' char columns in django?

前端 未结 3 418
耶瑟儿~
耶瑟儿~ 2020-12-13 15:59

I have a project written in Django. All fields that are supposed to store some strings are supposed to be in UTF-8, however, when I run

manage.py syncdb
         


        
3条回答
  •  轮回少年
    2020-12-13 16:32

    What is your MySQL encoding set to?

    For example, try the following from the command line:

     mysqld --verbose --help | grep character-set
    

    If it doesn't output utf8, then you'll need to set the output in my.cnf:

    [mysqld]
    character-set-server=utf8
    default-collation=utf8_unicode_ci
    
    [client]
    default-character-set=utf8
    

    This page has some more information:

    • http://www.zulutown.com/blog/tag/character-set/

提交回复
热议问题