運行Windows下創建的Django項目時,發生此錯誤! Database returned an invalid value in QuerySet.dates(). Are time zone definitions and pytz installed?
按提示先安裝pytz
1、先安裝easy_install:
sudo apt-get install python-setuptools
2、進入官網,獲取下載地址,使用wget命令下載:
wget https://pypi.python.org/packages/2.7/p/pytz/pytz-2014.4-py2.7.egg#md5=1e394a3b24ef6a5848c46bed82810915
3、安裝:
sudo easy_install pytz-2014.4-py2.7.egg
安裝完畢,不行,於是查找官方文檔:點擊打開鏈接 一頭霧水,仔細看提示,似乎是數據庫的原因,查看文檔:點擊打開鏈接
運行以下命令,重啟,搞定:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
備注:The
mysql_tzinfo_to_sql program loads the time zone tables in the
mysql
database. It is used on systems that have a
zoneinfo database (the set of files describing time zones). Examples of such systems are Linux, FreeBSD, Solaris, and Mac OS X. One likely location for these files is the
/usr/share/zoneinfo
directory (/usr/share/lib/zoneinfo
on Solaris). If your system does not have a zoneinfo database, you can use the downloadable package described in
Section 10.6, “MySQL Server Time Zone Support”.
本文由@The_Third_Wave(Blog地址:http://blog.csdn.net/zhanh1218)原創。還有未涉及的,會不定期更新,有錯誤請指正。
如果你看到這篇博文時發現沒有不完整,那是我為防止爬蟲先發布一半的原因,請看原作者Blog。
如果這篇博文對您有幫助,為了好的網絡環境,不建議轉載,建議收藏!如果您一定要轉載,請帶上後綴和本文地址。