gpt4 book ai didi

python - Django 从 1.4 升级到 1.8

转载 作者:太空宇宙 更新时间:2023-11-04 03:26:19 25 4
gpt4 key购买 nike

我正在尝试将一个项目从 Django 1.4 升级到 1.8。我调整了应用程序定义 as the docs say to :

wm/apps.py:

from django.apps import AppConfig

class WMConfig(AppConfig):
name="wm"
verbose_name="WebManager"

wm/__init__.py:

default_app_config = 'wm.apps.WMConfig'

现在的问题是,当我尝试通过浏览器访问应用程序时,出现 500 错误。 Apache 日志显示:

 mod_wsgi (pid=33242): Target WSGI script '/home/admusr/project/WebManager/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=33242): Exception occurred processing WSGI script '/home/admusr/project/WebManager/wsgi.py'.
Traceback (most recent call last):
File "/home/admusr/project/WebManager/wsgi.py", line 24, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 112, in create
mod = import_module(mod_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named wm.apps

如果我将 wm/__init__.py 更改为 default_app_config = 'apps.WMConfig' 然后它只是说 ImportError: No module named apps,所以问题是什么时候试图加载该模块。我还没有找到任何关于这种通用错误消息的信息。

最佳答案

尝试

default_app_config = 'Webmanager.wm.apps.WMConfig'

顺便说一句,the docs建议您直接在 INSTALLED_APPS 中使用应用配置的路径,而不是在应用的 __init__.py

中查看 default_app_config
INSTALLED_APPS = (
...
'Webmanager.wm.apps.WMConfig',

)

另一个问题是您的应用配置的 name属性。这应该是完整路径,即 WebManager.wm 而不是 wm

class WMConfig(AppConfig):
name="WebManager.wm"
verbose_name="WebManager"

关于python - Django 从 1.4 升级到 1.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32850792/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com