【问题标题】:heroku django server errorheroku django 服务器错误
【发布时间】:2017-02-15 07:52:16
【问题描述】:

尝试在heroku上部署django项目: https://crmtestnewone.herokuapp.com/crm/

按照此说明执行所有操作,但出现错误(服务器错误 (500)) https://github.com/DjangoGirls/tutorial-extensions/blob/master/heroku/README.md

2016-10-06T14:01:38.045036+00:00 heroku[router]: at=info method=GET path="/crm/" host=crmtestnewone.herokuapp.com request_id=4981504b-0314-48ee-8a1b-ef7c51062b8f fwd="95.108.174.232" dyno=web.1 connect=1ms service=53ms status=500 bytes=253

我只能进入/admin页面

2016-10-06T14:03:37.432783+00:00 heroku[router]: at=info method=GET path="/admin/" host=crmtestnewone.herokuapp.com request_id=854e9324-a660-4a4e-ac19-8a9e693331c2 fwd="95.108.174.232" dyno=web.1 connect=0ms service=85ms status=200 bytes=4891
2016-10-06T14:03:37.596058+00:00 heroku[router]: at=info method=GET path="/static/admin/css/dashboard.css" host=crmtestnewone.herokuapp.com request_id=65fcb7df-bbe8-4731-aabc-24c1886c7300 fwd="95.108.174.232" dyno=web.1 connect=0ms service=2ms status=404 bytes=304
2016-10-06T14:03:37.597996+00:00 heroku[router]: at=info method=GET path="/static/admin/css/base.css" host=crmtestnewone.herokuapp.com request_id=2ed877bd-c9f7-4b3d-b613-c479d75d1ef1 fwd="95.108.174.232" dyno=web.1 connect=0ms service=3ms status=404 bytes=299

你能给我一些建议吗?为什么管理页面工作(我可以在我的模型中创建对象),但看起来像没有任何样式的纯 html 而我的其他页面根本不工作?

更新:

settings.py

INSTALLED_APPS = (
'crm',
'bootstrapform',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',)

ROOT_URLCONF = 'dive_into.urls'

TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR, 'templates')],
    'APP_DIRS': True,
    'OPTIONS': {
        'context_processors': [
            'django.template.context_processors.debug',
            'django.template.context_processors.request',
            'django.contrib.auth.context_processors.auth',
            'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'dive_into.wsgi.application'

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True
STATIC_URL = '/static/'
LOGIN_REDIRECT_URL = '/crm/'
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
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

requirements.txt

Django==1.10.1
django-bootstrap-form==3.2.1
gunicorn==19.4.5
psycopg2==2.6.1
whitenoise==2.0.6
dj-database-url==0.4.0

【问题讨论】:

  • 你能把你的settings.py文件和要求,txt贴出来吗?
  • 更新问题
  • 您可以尝试在设置文件中将Debug 设置为True,然后检查url 抛出的错误吗?然后我们可以从那里开始工作。至于静态文件,这是因为 Django 在生产环境中不提供静态文件,您需要配置一些东西

标签: python django heroku


【解决方案1】:

更改为 debug=true,出现错误: 无法解析余数:来自 '=' in
的 '=' 问题出在: {% if search_clients = '无身份验证'%} 应该是== 它在本地运行良好。

纽特感谢您的帮助!

【讨论】:

    猜你喜欢
    • 2018-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-20
    • 1970-01-01
    • 2018-12-30
    • 2021-11-30
    • 2017-10-28
    相关资源
    最近更新 更多