2

Is my first time using django, and i wanted to deploy it in heroku. i am getting the next error "config['DATABASES']['default'] = dj_database_url.config(conn_max_age=MAX_CONN_AGE, ssl_require=True) TypeError: config() got an unexpected keyword argument 'ssl_require'" when i run

heroku run python manage.py migrate

I have tried doing the deployment following this guide that sould make the local database be sqlite3 and production postgresql https://medium.com/@BennettGarner/deploying-django-to-heroku-procfile-static-root-other-pitfalls-e7ab8b2ba33b i would actually like to set up both databases to postgresql, because i have it install in my local machine

This is settings.py

import os
import dj_database_url
import dotenv
import django_heroku

DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'crispy_forms',
    'users.apps.UsersConfig',
]

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 = 'myapp.urls'

WSGI_APPLICATION = 'myapp.wsgi.application'


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

DATABASES = {'default': {}}
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

# Password validation
# https://docs.djangoproject.com/en/2.2/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',
    },
]

PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

AUTH_USER_MODEL = 'users.CustomUser' 
LOGIN_REDIRECT_URL = 'home'
LOGOUT_REDIRECT_URL = 'home'
CRISPY_TEMPLATE_PACK = 'bootstrap4'

django_heroku.settings(locals())

del DATABASES['default']['OPTIONS']['sslmode']

This is the .env

DATABASE_URL=sqlite:///db.sqlite3

This is the Procfile

web: gunicorn grupo1-llevame.wsgi --log-file -

I would like that the migration passes and i dont found any advice so i decided to ask here any sugestion in how i nake the question is apreciated, this is just the second time i used the site.

Also when running

python migrate.py runserver

it shows this error "del DATABASES['default']['OPTIONS']['sslmode'] KeyError: 'OPTIONS'"

2
  • Well why are you doing that? Get rid of that del line. Commented May 27, 2019 at 19:11
  • i have removed that line and the problem disapear, but it is still not solved, i think i have set badly the database because it doesnt work in local nor in production. in local it gives me the error that the database engine is missing Commented May 27, 2019 at 19:36

1 Answer 1

1

heroku does not allow the use of sqlite in production. Use postgresql instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.