按照此处给出的说明,我一直在努力部署一个小型Django Web应用程序。我只是在开发中一直使用sqlite3来构建我的应用程序,并且在Django开发服务器上一切正常。当我尝试部署到Heroku时,出现错误“推送被拒绝,未检测到Cedar支持的应用程序”,但是我认为我拥有启动和运行应用程序所需的所有文件。已经花了几天时间没有成功,所以我会提出任何建议和帮助。下面是我的应用程序的草图,但是请在我的github repo上进行整个筛选。
landcrab/
landcrab/ <----- main project
settings/
__init__.py
base.py
local.py
production.py
__init__.py
urls.py
db.sqlite3
wsgi.py
vcrental/ <----- my app
admin.py
....
static/
....
.gitignore
db.sqlite3
manage.py
Procfile
requirements.txt
runtime.txt
在manage.py
,wsgi.py
我已经设定os.environ.setdefault("DJANGO_SETTINGS_MODULE", "landcrab.settings.production")
程序文件
web: gunicorn landcrab.wsgi --log-file -
requirements.txt(用于冻结点)
Django==1.7.1
dj-database-url==0.3.0
dj-static==0.0.6
django-toolbelt==0.0.1
gunicorn==19.1.1
jsmin==2.0.11
nose==1.3.4
psycopg2==2.5.4
pyparsing==2.0.3
python-dateutil==2.2
pytz==2014.9
six==1.8.0
static3==0.5.1
runtime.txt
python-3.4.2
对于我的设置文件,我尝试遵循以下结构
生产.py
from landcrab.settings.base import *
import dj_database_url
DEBUG = False
TEMPLATE_DEBUG = False
# Parse database configuration from $DATABASE_URL
DATABASES['default'] = dj_database_url.config()
# DATABASES['default'] = dj_database_url.config(default='postgres://user:pass@localhost/dbname')
# DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
# DATABASES = {'default': dj_database_url.config(default=os.environ.get('DATABASE_URL'))}
# DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Allow all host headers
ALLOWED_HOSTS = ['*']
最后是wsgi.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "landcrab.settings.production") #Edited by me
from django.core.wsgi import get_wsgi_application
#Added by me for Heroku
try:
from dj_static import Cling
application = Cling(get_wsgi_application())
except:
application = get_wsgi_application()
好吧,这很尴尬。在尝试部署到Heroku之前,我尚未提交更改。提交后,我能够无错误地进行部署。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句