将 Django 从 1.6.5 升级到 1.8.4 时出现问题
Issue when upgraded Django from 1.6.5 to 1.8.4
我是 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'
)
这个:
TEMPLATE_DIRS = (
CURRENT_PATH + '/templates'
)
是不是一个tuple
,它只是CURRENT_PATH + 'templates'
字符串。构成 tuple
的不是括号而是逗号,即:
>>> 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
的乱码表达式(我假设是出于可读性原因?)拼写为 ()
而不是 ,
除此特殊情况外,tuple
文字周围的括号在技术上是无用的,仅用于提高可读性。
我是 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'
)
这个:
TEMPLATE_DIRS = (
CURRENT_PATH + '/templates'
)
是不是一个tuple
,它只是CURRENT_PATH + 'templates'
字符串。构成 tuple
的不是括号而是逗号,即:
>>> 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
的乱码表达式(我假设是出于可读性原因?)拼写为 ()
而不是 ,
除此特殊情况外,tuple
文字周围的括号在技术上是无用的,仅用于提高可读性。