【问题标题】:How to configure wsgi application to migrate to django 1.7?如何配置 wsgi 应用程序以迁移到 django 1.7?
【发布时间】:2014-09-05 09:31:29
【问题描述】:

我正在尝试从 Django 1.6 升级到 1.7。

在运行 python manage.py runserver 时,出现以下错误:

django.core.exceptions.ImproperlyConfigured: WSGI application 'myapp.wsgi.application' could not be loaded; Error importing module: 'cannot import name get_path_info'

这是我的 settings.py 中的相应行:

WSGI_APPLICATION = 'myapp.wsgi.application'

这是我的 wsgi.py 文件:

import os

# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "myapp.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application

# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)

from dj_static import Cling
application = Cling(get_wsgi_application())

有解决办法吗?

【问题讨论】:

  • 看起来 Cling 导致错误。您可以删除Cling 并重试吗?
  • @ChillarAnand 如果我这样做,服务器会启动,但不再提供静态文件

标签: python django wsgi


【解决方案1】:

你使用的是什么版本的 dj_static?

我升级到 Django 1.7,但我的网站崩溃了,这让我想到了你的问题。

我检查了我的 dj_static 版本(我一直在使用 0.0.5,并注意到撰写本文时的最新版本是 0.0.6)。

更新 dj_static 后,我的网站在 Django 1.7 下似乎可以正常运行。

【讨论】:

  • 是的。你是怎么想到的?
猜你喜欢
  • 2015-10-09
  • 2014-12-29
  • 1970-01-01
  • 2015-04-08
  • 2014-08-21
  • 2021-01-21
  • 1970-01-01
  • 2014-12-21
  • 2014-12-13
相关资源
最近更新 更多