我正在尝试使用heroku启动django应用程序并出现以下错误
TypeError: config() got an unexpected keyword argument 'ssl_require'
运行时
'heroku run python manage.py migrate'
在使用Heroku的Django项目中 完整的输出是
Running python manage.py migrate on ⬢ serene-taiga-89672... up,run.6367 (Hobby)
Traceback (most recent call last):
File "manage.py",line 15,in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py",line 381,in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py",line 325,in execute
settings.INSTALLED_APPS
File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/__init__.py",line 57,in __getattr__
self._setup(name)
File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/__init__.py",line 44,in _setup
self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/__init__.py",line 107,in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/app/.heroku/python/lib/python3.7/importlib/__init__.py",line 127,in import_module
return _bootstrap._gcd_import(name[level:],package,level)
File "<frozen importlib._bootstrap>",line 1006,in _gcd_import
File "<frozen importlib._bootstrap>",line 983,in _find_and_load
File "<frozen importlib._bootstrap>",line 967,in _find_and_load_unlocked
File "<frozen importlib._bootstrap>",line 677,in _load_unlocked
File "<frozen importlib._bootstrap_external>",line 728,in exec_module
File "<frozen importlib._bootstrap>",line 219,in _call_with_frames_removed
File "/app/friendzone/settings.py",line 212,in <module>
django_heroku.settings(locals())
File "/app/.heroku/python/lib/python3.7/site-packages/django_heroku/core.py",line 69,in settings
config['DATABASES']['default'] = dj_database_url.config(conn_max_age=MAX_CONN_AGE,ssl_require=True)
文件settings.py是
import os
import dj_database_url
import django_heroku
import dotenv
# Build paths inside the project like this: os.path.join(BASE_DIR,...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '...'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
SECURE_CONTENT_TYPE_NOsnIFF = True
SECURE_BROWSER_XSS_FILTER = True
SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = False
X_FRAME_OPTIONS = 'DENY'
LETSENCRYPT_URL = os.environ.get('LETSENCRYPT_URL')
LETSENCRYPT_RESPONSE = os.environ.get('LETSENCRYPT_RESPONSE','')
ALLOWED_HOSTS = ['*']
INTERNAL_IPS = [
'127.0.0.1',]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware','whitenoise.middleware.WhiteNoiseMiddleware','django.contrib.sessions.middleware.Sessionmiddleware','django.middleware.locale.LocaleMiddleware','django.middleware.common.Commonmiddleware','django.middleware.csrf.CsrfViewMiddleware','debug_toolbar.middleware.DebugToolbarMiddleware','django.contrib.auth.middleware.Authenticationmiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',]
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.template.context_processors.media','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',],},]
WSGI_APPLICATION = 'friendzone.wsgi.application'
ASGI_APPLICATION = 'friendzone.routing.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2','NAME': '...','USER': '...','PASSWORD': '...','HOST': 'HOST','PORT': '5432',}
}
DATABASE_URL = 'postgres://...'
# Caches
# https://docs.djangoproject.com/en/2.1/topics/cache/
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache','LOCATION': '127.0.0.1:11211',}
}
# Celery settings
CELERY_BROKER_URL = 'redis://localhost:6379'
# activate Django-Heroku.
django_heroku.settings(locals())
DATABASES['default'] = dj_database_url.config(conn_max_age=600,ssl_require=True)
requirements.txt是
celery==4.3.0
daphne==2.3.0
Django==2.1.5
django-crispy-forms==1.7.2
django-debug-toolbar==2.0
django-extensions==1.5.9
django-heroku==0.3.1
dj-database-url==0.4.0
gunicorn==19.4.5
h5py==2.8.0
heapdict==1.0.0
hiredis==1.0.0
psycopg2==2.8.3
rabbitmq==0.2.0
redis==3.3.7
Twisted==19.7.0
twisted[http2]
twisted[tls]
whitenoise==2.0.6
使用
在本地运行应用程序时遇到相同的错误heroku local
或尝试部署应用程序时。 已经尝试删除ssl_require = True或将其设置为False,但出现相同的错误。