我一直在制作一个django应用程序,现在正试图将其部署到heroku。然而,当我打开它时,Server Error (500)说,日志是这样写的:2017-05-27T21:00:14.634310+00:00 heroku[router]: at=info method=GET path="/" host=remberit.herokuapp.com request_id=065d27c6-9211-458f-9fc6-bb677d43581e fwd="86.13.204.65" dyno=web.1 connect=0ms service=151ms status=500 bytes=387 protocol=https
这是我的settings.py (在learst学习相关的部分,但请询问你是否想要剩下的部分):
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, "staticfiles")
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
import dj_database_url
DATABASES['default'] = dj_database_url.config()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = ['*']
DEBUG = False
try:
from .local_settings import *
except ImportError:
pass下面是我的wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
#from whitenoise.django import DjangoWhiteNoise
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'remberit.settings')
django.setup()
application = get_wsgi_application()
#application = DjangoWhiteNoise(application)这是我的Procfile:
web: gunicorn remberit.wsgi这是我的runtime.txt:
python-3.5.2这是我的requirements.txt:
appdirs==1.4.3
dj-database-url==0.4.2
gunicorn==19.7.1
packaging==16.8
pyparsing==2.2.0
six==1.10.0
whitenoise==3.3.0
psycopg2==2.6.2下面是pip freeze的输出:
appdirs==1.4.3
dj-database-url==0.4.2
gunicorn==19.7.1
packaging==16.8
pyparsing==2.2.0
six==1.10.0
whitenoise==3.3.0此外,当我在本地使用gunicorn remberit.wsgi或python manage.py runserver运行应用程序时,它工作得很好,只有当我使用heroku时它才不起作用。
如果你需要更多的信息,请告诉我。
发布于 2017-09-26 04:03:22
其他可能解决您的问题的解决方案:注释掉或从白噪声中删除GzipManifestStaticFilesStorage。由于某些原因,这并不能很好地工作。
# STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'发布于 2019-08-05 10:41:15
正如mustapha-belkacim所说,你需要迁移你的应用程序:
heroku run python manage.py migrate发布于 2019-03-05 12:24:57
当我第一次将我的应用程序部署到heroku时,我遇到了类似的问题,在我的例子中,是数据库需要迁移。所以我不得不运行这个命令:
heroku run -a your-app-name python manage.py migrate请看一下本教程https://devcenter.heroku.com/articles/getting-started-with-python#provision-a-database
https://stackoverflow.com/questions/44221653
复制相似问题