2017-03-04 112 views
0

儘管在過去幾周裏我盡了最大的努力,但我一直試圖設置一個django框架,一直堅持在Pythonanywhere上部署WSGI文件。這裏有類似的話題,但沒有一個適用於我的案例。PythonAnywhere WSGI錯誤

我下面this tutorial,我得到了以下錯誤消息:

2017-03-04 22:28:05,284 :Error running WSGI application 
2017-03-04 22:28:05,285 :ImportError: No module named 'mysite' 
2017-03-04 22:28:05,285 : File "/var/www/iamcsongor_pythonanywhere_com_wsgi.py", line 11, in <module> 
2017-03-04 22:28:05,285 : application = get_wsgi_application() 
2017-03-04 22:28:05,285 : 
2017-03-04 22:28:05,285 : File "/home/iamcsongor/my-first-blog/myvenv/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application 
2017-03-04 22:28:05,285 : django.setup(set_prefix=False) 
2017-03-04 22:28:05,285 : 
2017-03-04 22:28:05,285 : File "/home/iamcsongor/my-first-blog/myvenv/lib/python3.5/site-packages/django/__init__.py", line 22, in setup 
2017-03-04 22:28:05,286 : configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) 
2017-03-04 22:28:05,286 : 
2017-03-04 22:28:05,286 : File "/home/iamcsongor/my-first-blog/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 53, in __getattr__ 
2017-03-04 22:28:05,286 : self._setup(name) 
2017-03-04 22:28:05,286 : 
2017-03-04 22:28:05,286 : File "/home/iamcsongor/my-first-blog/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup 
2017-03-04 22:28:05,287 : self._wrapped = Settings(settings_module) 
2017-03-04 22:28:05,287 : 
2017-03-04 22:28:05,287 : File "/home/iamcsongor/my-first-blog/myvenv/lib/python3.5/site-packages/django/conf/__init__.py", line 97, in __init__ 
2017-03-04 22:28:05,287 : mod = importlib.import_module(self.SETTINGS_MODULE) 

這裏是我的WSGI文件:

import os 

import sys 

path = '/home/iamcsongor/my-first-blog/firstweb' # use your own PythonAnywhere username here 
if path not in sys.path: 
    sys.path.append(path) 

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' 

from django.core.wsgi import get_wsgi_application 
from django.contrib.staticfiles.handlers import StaticFilesHandler 
application = StaticFilesHandler(get_wsgi_application()) 

我已經採取了一些screenshots of the codeGit Repo,如果你能幫助,我會很感激。謝謝

+0

你還沒有說過會發生什麼,出了什麼問題,或者看到了什麼錯誤。 –

+0

呃...好點! – Csongor

回答

1

正如錯誤所述,您的DJANGO_SETTINGS_MODULE環境變量設置爲「mysite」,但該目錄不存在。您的設置文件實際上顯示爲「firstweb」。

+0

謝謝丹尼爾,它工作!我也必須改變工作目錄,儘管......可能會出錯的東西太多了:) – Csongor