我是Django升级的新手,我尝试将版本从1.6.5升级到1.8.4。我使用sudo python setup.py install
手动安装了1.8.4。当我启动pycharm时,我得到以下错误。我检查__init__.py
以检查错误,并尝试找出1.8.4的示例文件以供参考。有人可以解释一下 - 如何逐步解决这些错误。
Failed to get real commands on module "albatross": python process died with code 1: Traceback (most recent call last):
File "/home/ritesh/Development/pycharm-4.5.3/helpers/pycharm/_jb_manage_tasks_provider.py", line 20, in <module>
django.setup()
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/conf/__init__.py", line 108, in __init__
"Please fix your settings." % setting)
django.core.exceptions.ImproperlyConfigured: The TEMPLATE_DIRS setting must be a tuple. Please fix your settings.
template_dir模板:
import os
CURRENT_PATH = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_DIRS = (
CURRENT_PATH + '/templates'
)
答案 0 :(得分:6)
这样:
TEMPLATE_DIRS = (
CURRENT_PATH + '/templates'
)
不一个tuple
,它只是CURRENT_PATH + 'templates'
字符串。什么使tuple
不是parens而是逗号,即:
>>> t = ("aaa")
>>> t
'aaa'
>>> type(t)
<type 'str'>
>>> t = "aaa", "bb"
>>> t
('aaa', 'bb')
>>> type(t)
<type 'tuple'>
>>> t = "aaa",
>>> t
('aaa',)
>>> type(t)
<type 'tuple'>
>>>
唯一的例外是空tuple
的litteral表达式(我假设出于可读性原因?)拼写为()
而不是,
除了这种特殊情况,tuple
附近的parens在技术上是无用的,仅用于可读性。