Configure WSGI with Django on OpenShift

会有一股神秘感。 提交于 2019-12-13 07:21:18

问题


I tried to configure WSGI with wsgi.py in my project folder

import os
import sys

sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR']))

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

virtenv = os.environ['OPENSHIFT_HOMEDIR'] + 'python/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 IOError:
    pass
#
# IMPORTANT: Put any additional includes below this line.  If placed above this
# line, it's possible required libraries won't be in your searchable path
#

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

but I have Internal Server Error 500

[Wed Jun 08 16:42:46 2016] [error] [client 127.9.155.129] ImportError: No module named project.settings

and I have this module available in my projet.

I tried some help like :

  • http://www.appsembler.com/blog/django-deployment-using-openshift/
  • How to configure Django on OpenShift?

Can you help my to launch my app on OpenShift

Thanks


回答1:


I had on the top of wsgi.py

os.path.join(os.environ['OPENSHIFT_HOMEDIR'], 'app-root/repo')

and I didn't have this error ! And I also put all my code under folder which have the name of my project in order to match

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


来源:https://stackoverflow.com/questions/37712689/configure-wsgi-with-django-on-openshift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!