gpt4 book ai didi

python - Heroku 和 Django - 关系不存在

转载 作者:行者123 更新时间:2023-12-03 17:35:28 25 4
gpt4 key购买 nike

我在 Heroku 上启动了一个应用程序,该应用程序运行 Django 2.0.1,并提供了 Postgres 资源。经过几次迭代后,我的 Procfile 如下所示:

文件

release: python manage.py migrate --noinput
web: gunicorn app.wsgi --log-file -

当我从 GitHub 部署时(不是从命令行......我之前没有从命令行部署,因为 GitHub 部署工作对我来说至关重要)一切正常。迁移运行正常,日志确认迁移时没有错误。事实上,部署到 Heroku 根本没有错误。

当我启动站点(强制它进入 Debug模式以查看错误)时,我在首页上收到此错误:
ProgrammingError at /
relation "posts_post" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "posts_post" INNER JOIN "u...

尝试加载管理站点时存在类似的错误:
ProgrammingError at /admin/login/
relation "django_site" does not exist
LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...
^

我遵循了 Django: relation "django_site" does not exist 中的建议迁移 sites首先,但这没有任何作用。

另外, this issue on GitHub is related ,但没有帮助。

澄清一下,该应用程序是可访问的。 Heroku 部署不会失败。该应用程序只是出错了。

追溯 (部分的)
Environment:


Request Method: GET
Request URL: https://somesite.herokuapp.com/

Django Version: 2.0.1
Python Version: 3.6.4
Installed Applications:
['django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.humanize',
'accounts.apps.AccountsConfig',
'analytics.apps.AnalyticsConfig',
'api_v1.apps.ApiV1Config',
'api_v2.apps.ApiV2Config',
'meta.apps.MetaConfig',
'posts.apps.PostsConfig',
'users.apps.UsersConfig',
'allauth',
'allauth.account',
'allauth.socialaccount',
'rest_framework']
Installed Middleware:
['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',
'whitenoise.middleware.WhiteNoiseMiddleware']



Traceback:

File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute
85. return self.cursor.execute(sql, params)

The above exception (relation "posts_post" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "posts_post" INNER JOIN "u...
^

为什么我会收到这些错误?我该怎么做才能让我的 Django 在 Heroku 上部署工作?

附加信息:

设置.py (出于安全考虑而被遮蔽)
ABSOLUTE_URL_OVERRIDES={}
ACCOUNT_AUTHENTICATION_METHOD='username_email'
ACCOUNT_EMAIL_REQUIRED=True
ACCOUNT_UNIQUE_EMAIL=True
ADMINS=[]
ALLOWED_HOSTS=['somesite.herokuapp.com']
APPEND_SLASH=True
AUTHENTICATION_BACKENDS=('django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend')
AUTH_PASSWORD_VALIDATORS='********************'
AUTH_USER_MODEL='users.User'
BASE_DIR='/app'
BLEACH_ALLOWED_ATTRIBUTES={...}
BLEACH_ALLOWED_PROTOCOLS=[...]
BLEACH_ALLOWED_TAGS=[...]
CACHES={'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
CACHE_MIDDLEWARE_ALIAS='default'
CACHE_MIDDLEWARE_KEY_PREFIX='********************'
CACHE_MIDDLEWARE_SECONDS=600
CSRF_COOKIE_AGE=31449600
CSRF_COOKIE_DOMAIN=None
CSRF_COOKIE_HTTPONLY=False
CSRF_COOKIE_NAME='csrftoken'
CSRF_COOKIE_PATH='/'
CSRF_COOKIE_SECURE=False
CSRF_FAILURE_VIEW='django.views.csrf.csrf_failure'
CSRF_HEADER_NAME='HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS=[]
CSRF_USE_SESSIONS=False
DATABASES={'default': {'ATOMIC_REQUESTS': False,
'AUTOCOMMIT': True,
'CONN_MAX_AGE': 0,
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'HOST': 'ec2-12-34-56-78.compute-1.amazonaws.com',
'NAME': 'ddr3sshvtab',
'OPTIONS': {},
'PASSWORD': '********************',
'PORT': 5432,
'TEST': {'CHARSET': None,
'COLLATION': None,
'MIRROR': None,
'NAME': None},
'TIME_ZONE': None,
'USER': 'jabbathehutt'}}
DATABASE_ROUTERS=[]
DATA_UPLOAD_MAX_MEMORY_SIZE=2621440
DATA_UPLOAD_MAX_NUMBER_FIELDS=1000
DATETIME_FORMAT='N j, Y, P'
DATETIME_INPUT_FORMATS=['%Y-%m-%d %H:%M:%S',
'%Y-%m-%d %H:%M:%S.%f',
'%Y-%m-%d %H:%M',
'%Y-%m-%d',
'%m/%d/%Y %H:%M:%S',
'%m/%d/%Y %H:%M:%S.%f',
'%m/%d/%Y %H:%M',
'%m/%d/%Y',
'%m/%d/%y %H:%M:%S',
'%m/%d/%y %H:%M:%S.%f',
'%m/%d/%y %H:%M',
'%m/%d/%y']
DATE_FORMAT='N j, Y'
DATE_INPUT_FORMATS=['%Y-%m-%d',
'%m/%d/%Y',
'%m/%d/%y',
'%b %d %Y',
'%b %d, %Y',
'%d %b %Y',
'%d %b, %Y',
'%B %d %Y',
'%B %d, %Y',
'%d %B %Y',
'%d %B, %Y']
DEBUG=True
DEBUG_PROPAGATE_EXCEPTIONS=False
DECIMAL_SEPARATOR='.'
DEFAULT_CHARSET='utf-8'
DEFAULT_CONTENT_TYPE='text/html'
DEFAULT_EXCEPTION_REPORTER_FILTER='django.views.debug.SafeExceptionReporterFilter'
DEFAULT_FILE_STORAGE='django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL='webmaster@localhost'
DEFAULT_INDEX_TABLESPACE=''
DEFAULT_TABLESPACE=''
DISALLOWED_USER_AGENTS=[]
EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST='smtp.mailgun.org'
EMAIL_HOST_PASSWORD='********************'
EMAIL_HOST_USER='postmaster@mg.mailgun.com'
EMAIL_PORT=587
EMAIL_SSL_CERTFILE=None
EMAIL_SSL_KEYFILE='********************'
EMAIL_SUBJECT_PREFIX='[Django] '
EMAIL_TIMEOUT=None
EMAIL_USE_LOCALTIME=False
EMAIL_USE_SSL=False
EMAIL_USE_TLS=True
ERROR_404_VIDEO_EMBED_LINK='https://www.youtube.com/embed/GSRG0TqxLWc'
ERROR_FEEDBACK_FORM_LINK='https://short.url/here'
FILE_CHARSET='utf-8'
FILE_UPLOAD_DIRECTORY_PERMISSIONS=None
FILE_UPLOAD_HANDLERS=
['django.core.files.uploadhandler.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FILE_UPLOAD_MAX_MEMORY_SIZE=2621440
FILE_UPLOAD_PERMISSIONS=None
FILE_UPLOAD_TEMP_DIR=None
FIRST_DAY_OF_WEEK=0
FIXTURE_DIRS=[]
FORCE_SCRIPT_NAME=None
FORMAT_MODULE_PATH=None
FORM_RENDERER='django.forms.renderers.DjangoTemplates'
GOOGLE_ANALYTICS_TRACKING_ID='UA-1111111-8'
IGNORABLE_404_URLS=[]
INSTALLED_APPS=['django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.humanize',
'accounts.apps.AccountsConfig',
'analytics.apps.AnalyticsConfig',
'api_v1.apps.ApiV1Config',
'api_v2.apps.ApiV2Config',
'meta.apps.MetaConfig',
'posts.apps.PostsConfig',
'users.apps.UsersConfig',
'allauth',
'allauth.account',
'allauth.socialaccount',
'rest_framework']
INTERNAL_IPS=[]
LANGUAGES=[...]
LANGUAGES_BIDI=['he', 'ar', 'fa', 'ur']
LANGUAGE_CODE='en-us'
LANGUAGE_COOKIE_AGE=None
LANGUAGE_COOKIE_DOMAIN=None
LANGUAGE_COOKIE_NAME='django_language'
LANGUAGE_COOKIE_PATH='/'
LOCALE_PATHS=[]
LOGGING={}
LOGGING_CONFIG='logging.config.dictConfig'
LOGIN_REDIRECT_URL='/accounts/profile/'
LOGIN_URL='/accounts/login/'
LOGOUT_REDIRECT_URL=None
MANAGERS=[]
MEDIA_ROOT=''
MEDIA_URL=''
MESSAGE_STORAGE='django.contrib.messages.storage.fallback.FallbackStorage'
MIDDLEWARE=['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',
'whitenoise.middleware.WhiteNoiseMiddleware']
MIGRATION_MODULES={}
MONTH_DAY_FORMAT='F j'
NUMBER_GROUPING=0
PASSWORD_HASHERS='********************'
PASSWORD_RESET_TIMEOUT_DAYS='********************'
PREPEND_WWW=False
REST_FRAMEWORK={'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticatedOrReadOnly',),
'PAGE_SIZE': 50}
ROOT_URLCONF='app.urls'
SECRET_KEY='********************'
SECURE_BROWSER_XSS_FILTER=False
SECURE_CONTENT_TYPE_NOSNIFF=False
SECURE_HSTS_INCLUDE_SUBDOMAINS=False
SECURE_HSTS_PRELOAD=False
SECURE_HSTS_SECONDS=0
SECURE_PROXY_SSL_HEADER=None
SECURE_REDIRECT_EXEMPT=[]
SECURE_SSL_HOST=None
SECURE_SSL_REDIRECT=False
SERVER_EMAIL='root@localhost'
SESSION_CACHE_ALIAS='default'
SESSION_COOKIE_AGE=1209600
SESSION_COOKIE_DOMAIN=None
SESSION_COOKIE_HTTPONLY=True
SESSION_COOKIE_NAME='sessionid'
SESSION_COOKIE_PATH='/'
SESSION_COOKIE_SECURE=False
SESSION_ENGINE='django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE=False
SESSION_FILE_PATH=None
SESSION_SAVE_EVERY_REQUEST=False
SESSION_SERIALIZER='django.contrib.sessions.serializers.JSONSerializer'
SETTINGS_MODULE='app.settings.production'
SHORT_DATETIME_FORMAT='m/d/Y P'
SHORT_DATE_FORMAT='m/d/Y'
SIGNING_BACKEND='django.core.signing.TimestampSigner'
SILENCED_SYSTEM_CHECKS=[]
SITE_ID=1
SITE_NAME='Super Cool Site'
SITE_TAGLINE="Super Cool Tagline."
STATICFILES_DIRS=[]
STATICFILES_FINDERS=['django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder']
STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT='/app/static'
STATIC_URL='/static/'
TEMPLATES=[{'APP_DIRS': True,
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['/app/templates', '/app/templates/allauth', '/app/templates/errors'],
'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',
'quest.context_processors.template_constants']}}]
TEST_NON_SERIALIZED_APPS=[]
TEST_RUNNER='django.test.runner.DiscoverRunner'
THOUSAND_SEPARATOR=','
TIME_FORMAT='P'
TIME_INPUT_FORMATS=['%H:%M:%S', '%H:%M:%S.%f', '%H:%M']
TIME_ZONE='UTC'
USE_ETAGS=False
USE_I18N=True
USE_L10N=True
USE_THOUSAND_SEPARATOR=False
USE_TZ=False
USE_X_FORWARDED_HOST=False
USE_X_FORWARDED_PORT=False
VERSION='1.0.0-alpha.2'
WSGI_APPLICATION='app.wsgi.application'
X_FRAME_OPTIONS='SAMEORIGIN'
YEAR_MONTH_FORMAT='F Y'

最佳答案

尝试运行

$Heroku run python manage.py migrate
在您的终端中。

关于python - Heroku 和 Django - 关系不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48644744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com