Python Django部署到Heroku H10错误

mnemlml8  于 2023-05-01  发布在  Go
关注(0)|答案(1)|浏览(305)

我正在尝试将Python中的API部署到Heroku。我得到了这个错误,我不知道如何修复它们。

at=error code=H10 desc="App crashed" method=GET path="/" host=pythonapisfind.herokuapp.com request_id=a0e39942-e0d5-4159-87fa-b06e997122b6 fwd="217.97.50.218" dyno= connect= service= status=503 bytes= protocol=https
2020-12-09T09:06:17.055412+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pythonapisfind.herokuapp.com request_id=b76f9c8c-a187-4516-9338-f01bca9eb726 fwd="217.97.50.218" dyno= connect= service= status=503 bytes= protocol=https
from pathlib import Path
from environ import Env

BASE_DIR = Path(__file__).resolve().parent.parent

env = Env()
env.read_env(env_file='.env')

SECRET_KEY = env('DJANGO_SECRET_KEY')
DEBUG = env.bool('DJANGO_DEBUG')

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'drf_yasg',
    'corsheaders',
    'rest_framework',

    'apps.core',
    'apps.offers'
]

MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'project.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        '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 = 'project.wsgi.application'

# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': env("DATABASE_NAME"),
        'USER': env("DATABASE_USER"),
        'PASSWORD': env("DATABASE_PASSWORD"),
        'HOST': env("DATABASE_HOST"),
        'PORT': env("DATABASE_PORT"),
    }
}

# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = '/static/'

ALLOWED_HOSTS = ['pythonapisfind.herokuapp.com', '127.0.0.1']

CORS_ORIGIN_ALLOW_ALL = True
asgiref==3.3.1
certifi==2020.12.5
chardet==3.0.4
coreapi==2.3.3
coreschema==0.0.4
Django==3.1.4
django-cors-headers==3.5.0
django-environ==0.4.5
djangorestframework==3.12.2
drf-yasg==1.20.0
idna==2.10
inflection==0.5.1
itypes==1.2.0
Jinja2==2.11.2
MarkupSafe==1.1.1
packaging==20.7
postgres==3.0.0
psycopg2-binary==2.8.6
psycopg2-pool==1.1
pyparsing==2.4.7
pytz==2020.4
requests==2.25.0
ruamel.yaml==0.16.12
ruamel.yaml.clib==0.2.2
sqlparse==0.4.1
uritemplate==3.0.1
urllib3==1.26.2
gunicorn ==20.0.4

vc9ivgsu

vc9ivgsu1#

您的 www.example.com 的设置位置设置错误
变更

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')

相关问题