Django学习笔记

作者: 勇不言弃92 | 来源:发表于2017-08-30 14:23 被阅读9次

    1.从github上获取的项目需要配置python解析器,报错“Cannot find Python interpreter for selected module”,解决方式:按照下面两步选择运行环境


    屏幕快照 2017-08-30 14.14.27.png
    屏幕快照 2017-08-30 14.14.34.png

    2.运行“makemigrations”和“migrate”时报错“1366, "Incorrect string value”是因为mysql编码问题导致,

    mysql> show variables like "%char%";
    +--------------------------+--------------------------------------------------------+
    | Variable_name            | Value                                                  |
    +--------------------------+--------------------------------------------------------+
    | character_set_client     | utf8                                                   |
    | character_set_connection | utf8                                                   |
    | character_set_database   | latin1                                                 |
    | character_set_filesystem | binary                                                 |
    | character_set_results    | utf8                                                   |
    | character_set_server     | latin1                                                 |
    | character_set_system     | utf8                                                   |
    | character_sets_dir       | /usr/local/mysql-5.7.11-osx10.9-x86_64/share/charsets/ |
    +--------------------------+--------------------------------------------------------+
    8 rows in set (0.01 sec)
    
    

    关闭mysql
    MAC电脑需要在“/private/etc”中新建“my.cnf”文件(如果已有则不需要新建),添加以下数据

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

    打开mysql验证

    mysql> show variables like "%char%";
    +--------------------------+--------------------------------------------------------+
    | Variable_name            | Value                                                  |
    +--------------------------+--------------------------------------------------------+
    | character_set_client     | utf8                                                   |
    | character_set_connection | utf8                                                   |
    | character_set_database   | utf8                                                 |
    | character_set_filesystem | binary                                                 |
    | character_set_results    | utf8                                                   |
    | character_set_server     | utf8                                                 |
    | character_set_system     | utf8                                                   |
    | character_sets_dir       | /usr/local/mysql-5.7.11-osx10.9-x86_64/share/charsets/ |
    +--------------------------+--------------------------------------------------------+
    8 rows in set (0.01 sec)
    

    相关文章

      网友评论

        本文标题:Django学习笔记

        本文链接:https://www.haomeiwen.com/subject/sletjxtx.html