Django mysql arabic encoding(Django mysql 阿拉伯语编码)
问题描述
我有一个带有 mysql 数据库的 django 应用程序.我们正在尝试推出该网站的阿拉伯语版本.目前的语言是英语.出于某种原因,当我通过管理面板用阿拉伯语写一些东西并单击保存时,它显示 ????而不是我写的阿拉伯语单词.我不知道如何解决它.
I've a django app with a mysql database. We are trying to launch the Arabic version of the website. The current language is English. For some reason when I write something in Arabic through the admin panel and click save, it shows ???? instead of the Arabic word i wrote. I've no idea how to fix it.
我按照这个 post 并添加了 #-*- coding: utf-8 -*-
到我的 admin.py、models.py 和 views.py 文件.没用
I followed this post and added #-*- coding: utf-8 -*-
to my admin.py, models.py and views.py files. It didn't work
我还将这些添加到 my.conf mysql 文件中以更改字符集.它也没有用.
I also added these to my.conf mysql file to change the character set. It didn't work either.
character-set-server=utf8
collation-server=utf8_unicode_ci
init_connect='set collation_connection = utf8_unicode_ci;'
推荐答案
可能发生的事情:
- 你有 utf8 编码的数据(好)
SET NAMES latin1
有效(默认,但错误)- 列被声明为
CHARACTER SET latin1
(默认,但错误)
- you had utf8-encoded data (good)
SET NAMES latin1
was in effect (default, but wrong)- the column was declared
CHARACTER SET latin1
(default, but wrong)
请提供SHOW CREATE TABLE
,以便我们可以制定ALTER
来修复列.
Please provide SHOW CREATE TABLE
so we can formulate an ALTER
to fix the columns.
Django 需要 client_encoding: 'UTF8'
;抱歉,我不知道去哪里了.
Django needs client_encoding: 'UTF8'
; sorry, I don't know where that goes.
这篇关于Django mysql 阿拉伯语编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Django mysql 阿拉伯语编码


- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- SQL 临时表问题 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01