You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mezzanine -- 'max_digits' must be great or equal to 'decimal_places' on OpenBSD/'ascii' codec can't encode characters in position 58-61: ordinal not in range/Python修改編碼
#216
Open
maxchen989 opened this issue
Jul 5, 2023
· 0 comments
Mezzanine -- 'max_digits' must be great or equal to 'decimal_places' on OpenBSD/'ascii' codec can't encode characters in position 58-61: ordinal not in range/Python修改編碼
最近在部署Mezzanine時, 遇到了這個問題.
這是Mezzanine其中的一個app所引起的error.
目前找到的解法如下
在local_setting.py中加入
SHOP_CURRENCY_LOCALE = 'en_US.UTF-8'
不過這會導致, 後續連結Database造成編碼問題.
blog的某些post會有error:
`'ascii' codec can't encode characters in position 58-61: ordinal not in range(128)`
Mezzanine -- 'max_digits' must be great or equal to 'decimal_places' on OpenBSD/'ascii' codec can't encode characters in position 58-61: ordinal not in range/Python修改編碼
最近在部署Mezzanine時, 遇到了這個問題.
這是Mezzanine其中的一個app所引起的error.
目前找到的解法如下
在local_setting.py中加入
SHOP_CURRENCY_LOCALE = 'en_US.UTF-8'
不過這會導致, 後續連結Database造成編碼問題.
blog的某些post會有error:
尚未釐清
後記:
我比對了Local 正常運作的環境與DigitalOcean的環境, 並將其同步為
註:vir是python virtualenv, sys則是系統編碼
同步語法:
同步到最後找不到此項編碼:
Chinese (Traditional)_Taiwan.950
因此最後決定就維持目前這樣.
經測試發現, Tile中有中文的post都會報ascii錯誤, 而文章內容有中文的不會影響.
並且發現如果一開始tile設定為英文或是數字, 就算之後再改為中文也不會報錯.
調查後發現, 是與django抓取url有關.
如何讓Django處理utf8 url.
但在經過測試, 如果不使用apache轉送, 直接使用manage.py runserver是不會有以上問題的.
所以原因就是apache的encoding問題!
去/etc/apache2/envvars,加入以下兩個設定, 此問題就解決了
折騰好久!
參考來源:
stephenmcd/cartridge#330
https://docs.oracle.com/cd/E19683-01/816-3982/utf8-98/index.html
https://blog.longwin.com.tw/2018/09/python3-unicode-encode-error-ascii-codec-2018/
https://stackoverflow.com/questions/1629699/locale-getlocale-problems-on-osx
https://ephrain.net/linux-%E7%92%B0%E5%A2%83%E8%AE%8A%E6%95%B8-lang-lc_-lc_all-%E5%B0%8D-l10n-gettext-%E7%9A%84%E5%BD%B1%E9%9F%BF/
https://blog.csdn.net/sinat_24648637/article/details/84190482
stephenmcd/cartridge#164
https://docs.djangoproject.com/zh-hans/3.2/howto/deployment/wsgi/modwsgi/
tags:
Mezzanine
Apache
Django
The text was updated successfully, but these errors were encountered: