问题
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