2014-09-04 87 views
3

我想從Django 1.6升級到1.7。如何配置wsgi應用程序遷移到django 1.7?

當運行蟒蛇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()) 

任何想法解決它?

+0

看起來像'Cling'導致錯誤。你能否刪除'Cling'並再試一次? – ChillarAnand 2014-09-04 19:32:39

+0

@ChillarAnand如果我這樣做,服務器啓動,但不再提供靜態文件 – egoz 2014-09-04 19:40:06

回答

3

您使用的是什麼版本的dj_static?

我升級到Django 1.7,我的網站壞了,讓我回到你的問題。

我檢查了我的dj_static版本(我一直在使用0.0.5,並注意到寫這篇文章時的最新版本是0.0.6)。

更新dj_static後,我的網站似乎在Django 1.7下正常運行。

+0

Yay。你怎麼看待這個問題? – GreenAsJade 2014-10-19 08:13:26