0

I got Error500 when I turn DEBUG True on settings.py but everything is okay when DEBUG is False. python manage.py collectstatic is okay too. Here my settings.py. I will appreciated your help. I use Django 2.2 version.

Django settings

"""
Django settings for samamarche project.

Generated by 'django-admin startproject' using Django 2.2.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import dj_database_url
import os
import django_heroku
if os.environ.get('ENV') == 'PRODUCTION':
    # ...
    db_from_env = dj_database_url.config(conn_max_age=500)
    #DATABASES['default'] = dj_database_url.config(conn_max_age=600, ssl_require=True)
    DATABASES['default'].update(db_from_env)

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SECRET_KEY = os.environ.get('SECRET_KEY', 'xxxxxxxxxxxxxxx')
DEBUG = True
# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'phonenumber_field',
    'marche',
    'cart',
    'commandes',
    'payment',
    'coupons',
    #'accounts',
    'crispy_forms',
    'users',
]
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'
]
Seydina
  • 61
  • 1
  • 7
  • You need add `STATICFILES_DIRS ` when `DEBUG = True`. See more https://stackoverflow.com/questions/24022558/differences-between-staticfiles-dir-static-root-and-media-root – Nguyễn Vũ Thiên Apr 24 '21 at 05:51

1 Answers1

0

i think adding ALLOWED_HOSTS = ['*'] will solve the problem