Raj*_*eev 3 python django utf-8 django-views
在Django中,插入数据库时如何使用unicode
例:
name =request.POST["name"] //This may be in Chinese or any other lanuages
usr = Users(name=name)
usr.save()
Run Code Online (Sandbox Code Playgroud)
Cent os中使用的Python版本是python 2.4.3,mod python版本是1.2.1_p2-1
您应该检查您的数据库在尝试插入的表上是否具有utf8字符集。
对于mysql
show create table TableName;
Run Code Online (Sandbox Code Playgroud)
更改编码
alter table TableName DEFAULT CHARACTER SET utf8;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1964 次 |
| 最近记录: |