问题描述
我正在通过官方Django教程使用版本1.6.1和版本2.7.5的python在OSX上。我在第2部分工作,这是管理界面。当我尝试去/ admin / polls / poll /时,我收到以下错误报告: 在/ admin / polls / poll /
此查询需要pytz,但未安装。
请求方法:GET
请求URL:http://127.0.0.1:8000/admin/polls/poll/
Django版本:1.6.1
异常类型:不正确配置
异常值:
此查询需要pytz,但未安装。
异常位置:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py在datetime_trunc_sql第196行
Python可执行文件:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python版本:2.7.5
我尝试通过安装pip(需要安装setuptools)来安装pytz,但这没有任何区别。另外,我第二次浏览本教程,我知道一个月前没有遇到这个问题。可能更新到小牛已经引起了一些问题?
继续搜索django和pytz之后,我发现了1.6 Django发行说明,其中提到您现在必须安装pytz才能使用Sqlite3,如果USET_TZ = True,则在settings.py中。
我不知道USE_TZ对您的应用程序有什么影响,但将该值设置为False可以让我在本教程中继续。我希望Django教程更新以反映这一变化。
I'm currently working through the official Django tutorial using version 1.6.1 and version 2.7.5 of python on OSX. I'm working on part 2, which is the admin interface. When I attempt to go to /admin/polls/poll/, I get the following error report:
ImproperlyConfigured at /admin/polls/poll/
This query requires pytz, but it isn't installed.
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/polls/poll/
Django Version: 1.6.1
Exception Type: ImproperlyConfigured
Exception Value:
This query requires pytz, but it isn't installed.
Exception Location: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py in datetime_trunc_sql, line 196
Python Executable: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.5
I attempted to install pytz by installing pip (which required installing setuptools) but this made no difference. Also, I am going through this tutorial for a second time, and I know I didn't run into this problem a month ago. Could updating to Mavericks have caused some problem?
After continuing to search for django and pytz, I found the 1.6 Django release notes, which mention that you must now install pytz to work with Sqlite3 if USE_TZ=True in your settings.py.
I don't know what effect USE_TZ has on your application, but setting that value to False allows me to proceed in the tutorial. I would hope that the Django tutorial is updated to reflect this change.
这篇关于Django教程 - 未正确配置的异常(pytz未安装)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!