[英]Failed to find attribute 'application' in 'Django project name'. Heroku app deploy
I deployed my Django project with Heroku successfully but when I view my app I get an error page saying我使用 Heroku 成功部署了我的 Django 项目,但是当我查看我的应用程序时,我收到一个错误页面
Application error An error occurred in the application and your page could not be served.
应用程序错误 应用程序发生错误,无法提供您的页面。 If you are the application owner, check your logs for details.
如果您是应用程序所有者,请查看您的日志以获取详细信息。 You can do this from the Heroku CLI with the command
您可以从 Heroku CLI 使用以下命令执行此操作
heroku logs --tail
when I put it in terminal I get this message当我把它放在终端时,我收到了这条消息
2021-03-16T08:50:34.762969+00:00 app[web.1]: [2021-03-16 08:50:34 +0000] [4] [INFO] Starting gunicorn 20.0.4
2021-03-16T08:50:34.763493+00:00 app[web.1]: [2021-03-16 08:50:34 +0000] [4] [INFO] Listening at: http://0.0.0.0:55178 (4)
2021-03-16T08:50:34.763587+00:00 app[web.1]: [2021-03-16 08:50:34 +0000] [4] [INFO] Using worker: sync
2021-03-16T08:50:34.767113+00:00 app[web.1]: [2021-03-16 08:50:34 +0000] [8] [INFO] Booting worker with pid: 8
2021-03-16T08:50:34.770278+00:00 app[web.1]: Failed to find attribute 'application' in 'ourUI'.
2021-03-16T08:50:34.770403+00:00 app[web.1]: [2021-03-16 08:50:34 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-03-16T08:50:34.794976+00:00 app[web.1]: [2021-03-16 08:50:34 +0000] [9] [INFO] Booting worker with pid: 9
2021-03-16T08:50:34.799785+00:00 app[web.1]: Failed to find attribute 'application' in 'ourUI'.
2021-03-16T08:50:34.799990+00:00 app[web.1]: [2021-03-16 08:50:34 +0000] [9] [INFO] Worker exiting (pid: 9)
2021-03-16T08:50:34.904166+00:00 app[web.1]: [2021-03-16 08:50:34 +0000] [4] [INFO] Shutting down: Master
2021-03-16T08:50:34.904279+00:00 app[web.1]: [2021-03-16 08:50:34 +0000] [4] [INFO] Reason: App failed to load.
2021-03-16T08:50:37.000000+00:00 app[api]: Build succeeded
2021-03-16T08:50:39.982849+00:00 heroku[web.1]: Starting process with command `gunicorn ourUI`
2021-03-16T08:50:42.245442+00:00 heroku[web.1]: Process exited with status 4
2021-03-16T08:50:42.310353+00:00 heroku[web.1]: State changed from starting to crashed
2021-03-16T08:50:42.140009+00:00 app[web.1]: [2021-03-16 08:50:42 +0000] [4] [INFO] Starting gunicorn 20.0.4
2021-03-16T08:50:42.140941+00:00 app[web.1]: [2021-03-16 08:50:42 +0000] [4] [INFO] Listening at: http://0.0.0.0:31341 (4)
2021-03-16T08:50:42.141087+00:00 app[web.1]: [2021-03-16 08:50:42 +0000] [4] [INFO] Using worker: sync
2021-03-16T08:50:42.145144+00:00 app[web.1]: [2021-03-16 08:50:42 +0000] [8] [INFO] Booting worker with pid: 8
2021-03-16T08:50:42.148479+00:00 app[web.1]: Failed to find attribute 'application' in 'ourUI'.
2021-03-16T08:50:42.148628+00:00 app[web.1]: [2021-03-16 08:50:42 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-03-16T08:50:42.182612+00:00 app[web.1]: [2021-03-16 08:50:42 +0000] [4] [INFO] Shutting down: Master
2021-03-16T08:50:42.182707+00:00 app[web.1]: [2021-03-16 08:50:42 +0000] [4] [INFO] Reason: App failed to load.
2021-03-16T08:51:10.997193+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hdpcapp.herokuapp.com request_id=ff5bdf78-e5b6-41cf-80e6-1bdf1d5f81f5 fwd="51.39.244.104" dyno= connect= service= status=503 bytes= protocol=https
this is my Procfile这是我的 Procfile
web: gunicorn ourUI
requirement.txt需求.txt
asgiref==3.3.1
Django==3.1.7
gunicorn==20.0.4
pytz==2021.1
sqlparse==0.4.1
whitenoise==5.2.0
ourUI is my Django project ourUI 是我的 Django 项目
ourUI/setting.py我们的UI/setting.py
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'a-skd+xzh4&dka$6(wl5q*#7%b%q8a%aijy70cc#(5mw6+y25-'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['hdpcapp.herokuapp.com', '127.0.0.1']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'TheUI'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.whitenoiseMiddleware',
'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 = 'ourUI.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 = 'ourUI.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# 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_ROOT = os.path.join(BASE_DIR, 'dtsticfiles')
STATIC_URL = '/static/'
ourUI/wsgi.py我们的UI/wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ourUI.settings')
application = get_wsgi_application()
I'm new to Django and heroku I hope I can get a solution for this我是 Django 和 heroku 的新手,我希望我能找到解决方案
I solved this problem by editing my Procfile to我通过编辑我的 Procfile 解决了这个问题
web: gunicorn ourUI.wsgi
and fixed w and n to W and N in (setting.py)并将 w 和 n 固定为 (setting.py) 中的 W 和 N
'whitenoise.middleware.whitenoiseMiddleware',
to至
'whitenoise.middleware.WhiteNoiseMiddleware',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.