Home > Net >  Django heroku internal server error after deploying
Django heroku internal server error after deploying

Time:10-11

I have deployed my django app to heroku and I am getting Internal Server Error in the website.

settings.py :

'ALLOWED_HOSTS = ['http://127.0.0.1:8000/','https://stripetestdjango.herokuapp.com/', 'localhost']

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',
]


MEDIA_URL = '/images/'


STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)


MEDIA_ROOT = BASE_DIR / 'static/images'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

# STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

STATICFILES_STORAGE =  'django.contrib.staticfiles.storage.StaticFilesStorage' 



if os.getcwd() == '/app':
    DEBUG = False

The heroku log shows the below:

enter image description here

I have .env file. How to push that to server as well as I am deploying using heroku. I guess the error is it is not able to find my .env file.

Please feel free to ask for more details if needed.

CodePudding user response:

You should never push an .env file containing sensitive data (ie SECRET_KEY_STRIPE) but rather use Create Heroku ConfigVar

  • Related