如下:
復制代碼 代碼如下:
Warning at /admin/assets/add/
Incorrect string value: '\xE5\x93\x88\xD5\x92\x88...' for column 'Name' at row 1
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/assets/add/
Django Version: 1.2.3
Exception Type: Warning
Exception Value:
Incorrect string value: '\xE5\x93\x88\xD5\x92\x88...' for column 'Name' at row 1
Exception Location: /usr/lib/pymodules/python2.7.1/MySQLdb/cursors.py in _warning_check, line 82
Python Executable: /usr/bin/python
Python Version: 2.7.1
初步判斷 應該是mysql的問題 [代研究本質問題]:
在my.ini 添加如下:
復制代碼 代碼如下:
[client]
character-set-client = utf8
default-character-set = utf8
[mysqld]
character-set-server = utf8
character-set-filesystem = utf8[mysql]
init_connect='SET NAMES utf8'
[mysql]
default-character-set=utf8
重啟mysql服務器,問題解決。
查看創建mysql數據庫的默認編碼:
show create database db_name;
更改已經創建的db的編碼:
alter database db_name character set utf8 collate utf8_general_ci;
查看數據庫相關信息:
mysql>status
查看數據庫相關信息2:
mysql> show variables like 'char%';