我终于弄明白了。首先要做的是启动一个openshift应用程序并编辑setup.py文件:
rhc app create -a APPNAME -t python-2.6cd APPNAMEvim setup.py
您需要取消注释“ install_requires = [‘Django> = 1.3’]”
然后,您可以提交到服务器:
git commit -a -m "Initialization"git push
默认情况下,它将安装django
1.4,但我认为您可以在setup.py中选择具有正确安装要求的另一个版本。无论如何,您必须在计算机和服务器上运行以下相同的Django版本。
创建您的django项目:
cd wsgidjango-admin.py startproject PROJECTNAME
然后,您必须编辑文件应用程序,将整个内容替换为:
#!/usr/bin/pythonimport os, sysos.environ['DJANGO_SETTINGS_MODULE'] = 'PROJECTNAME.settings'sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi', 'PROJECTNAME'))virtenv = os.environ['APPDIR'] + '/virtenv/'os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.6/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# from django.core.handlers import wsgiapplication = wsgi.WSGIHandler()
最后,您可以提交修改:
cd ..git add .git commit -a -m "Project Creation"git push
您应该看到django欢迎页面。现在,您可以编辑设置并导入没有不必要内容的Django应用程序



