2014-04-04 24 views
2

我試圖用命令來運行我的Django 1.6的項目在本地(從openshift下載): $ python3.3 manage.py runserver命令如何在本地運行OpenShift Django項目?

,並得到錯誤:

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0xb691592c> 
Traceback (most recent call last): 
    File "/usr/local/lib/python3.3/dist-packages/Django-1.6-py3.3.egg/django/utils/module_loading.py", line 21, in import_by_path 
    module = import_module(module_path) 
    File "/usr/lib/python3.3/importlib/__init__.py", line 90, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
    File "<frozen importlib._bootstrap>", line 1584, in _gcd_import 
    File "<frozen importlib._bootstrap>", line 1565, in _find_and_load 
    File "<frozen importlib._bootstrap>", line 1529, in _find_and_load_unlocked 
ImportError: No module named 'wsgi' 

During handling of the above exception, another exception occurred: 

............................................................ 
.......................................................... 
................................................... 
    File "<frozen importlib._bootstrap>", line 1584, in _gcd_import 
    File "<frozen importlib._bootstrap>", line 1565, in _find_and_load 
    File "<frozen importlib._bootstrap>", line 1529, in _find_and_load_unlocked 
django.core.exceptions.ImproperlyConfigured: WSGI application 'wsgi.application' could not be loaded; Error importing module wsgi: "No module named 'wsgi'" 

但在openshift.com有用。我如何在本地運行它以進行快速調試?

回答

0

設置了一個層次結構類似standard example的應用程序,我不得不做以下修改:

在manage.py:

# Add the root to the path to support local testing with 
# runserver/WSGI_APPLICATION 
sys.path.append(os.path.join(os.path.dirname(__file__), '..','..')) 

在settings.py:

WSGI_APPLICATION = 'wsgi.application.application' 

WSGI_APPLICATION變量只用於runserver,我相信,所以不會影響已部署的應用程序。

5

這個問題稍晚,但我有同樣的問題,並提出了一種替代解決方案。

我加

sys.path.append(os.path.join(os.path.dirname(__file__), '..', "..")) 

內openshift/manage.py

一個else在mysite的/ wsgi.py

else: 
    from django.core.wsgi import get_wsgi_application 
    application = get_wsgi_application() 
相關問題