問題描述
我有一個帶有 mysql 數(shù)據(jù)庫的 django 應(yīng)用程序.我們正在嘗試推出該網(wǎng)站的阿拉伯語版本.目前的語言是英語.出于某種原因,當(dāng)我通過管理面板用阿拉伯語寫一些東西并單擊保存時,它顯示 ????而不是我寫的阿拉伯語單詞.我不知道如何解決它.
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;'
推薦答案
可能發(fā)生的事情:
- 你有 utf8 編碼的數(shù)據(jù)(好)
SET NAMES latin1
有效(默認(rèn),但錯誤)- 列被聲明為
CHARACTER SET latin1
(默認(rèn),但錯誤)
- 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)
請?zhí)峁?code>SHOW CREATE TABLE,以便我們可以制定ALTER
來修復(fù)列.
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.
這篇關(guān)于Django mysql 阿拉伯語編碼的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!