2

我正在使用 Django/Python 2.7 测试 OpenShift,我得到了这个:

127.5.232.1 - - [2013-06-28 17:01:37] "GET / HTTP/1.1" 500 161 0.013770
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/gevent/pywsgi.py", line 438, in handle_one_response
    self.run_application()
  File "build/bdist.linux-x86_64/egg/gevent/pywsgi.py", line 424, in run_application
    self.result = self.application(self.environ, self.start_response)
  File "/var/lib/openshift/51cd757de0b8cd31130000c1/python/virtenv/lib/python2.7/site-packages/Django-1.5.1-py2.7.egg/django/core/handlers/wsgi.py", line 236, in __call__
    self.load_middleware()
  File "/var/lib/openshift/51cd757de0b8cd31130000c1/python/virtenv/lib/python2.7/site-packages/Django-1.5.1-py2.7.egg/django/core/handlers/base.py", line 45, in load_middleware
    for middleware_path in settings.MIDDLEWARE_CLASSES:
  File "/var/lib/openshift/51cd757de0b8cd31130000c1/python/virtenv/lib/python2.7/site-packages/Django-1.5.1-py2.7.egg/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/var/lib/openshift/51cd757de0b8cd31130000c1/python/virtenv/lib/python2.7/site-packages/Django-1.5.1-py2.7.egg/django/conf/__init__.py", line 48, in _setup
    self._wrapped = Settings(settings_module)
  File "/var/lib/openshift/51cd757de0b8cd31130000c1/python/virtenv/lib/python2.7/site-packages/Django-1.5.1-py2.7.egg/django/conf/__init__.py", line 134, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'www_project.settings' (Is it on sys.path?): No module named openshiftlibs
<WSGIServer fileno=6 address=127.5.232.1:8080>: Failed to handle request:
  request = GET /favicon.ico HTTP/1.1 from ('127.5.232.1', 22073)
  application = <django.core.handlers.wsgi.WSGIHandler object at 0x7f65c45dc510>

我做了什么?:

  1. 使用 rhc 命令行工具创建应用程序
  2. 创建了一个“隔离的 Django 应用程序”并复制到 wsgi 目录中
  3. 替换了官方 django 示例的应用程序和设置文件
  4. 推动并尝试

这是我的申请文件:

#!/usr/bin/env python
import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'www_project.settings'
sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi', 'www_project'))
virtenv = os.environ['OPENSHIFT_REPO_DIR'] + '/virtenv/'
os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.7/site-packages')
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
    execfile(virtualenv, dict(__file__=virtualenv))
except:
    pass

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

我的问题:

我错过了什么?,如果您需要其他内容,请告诉我。提前致谢!

4

3 回答 3

1

我错过了 openshiftlibs.py 文件

于 2013-07-01T16:38:09.767 回答
0

我遇到了这个问题并用这篇文章解决了它

http://appsembler.com/blog/django-deployment-using-openshift/

于 2013-06-28T23:19:22.997 回答