I got the same problem, I have try everything to get it to work, but no luck.
I got a Disks with the path /app/media
My Settings.py look like this:
from pathlib import Path
from decouple import config
import dj_database_url
import os
Build paths inside the project like this: BASE_DIR / ‘subdir’.
BASE_DIR = Path(file).resolve().parent.parent
SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config(‘SECRET_KEY’)
SECURITY WARNING: don’t run with debug turned on in production!
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’,
‘app’, # Add this line to include the app in the project
]
MIDDLEWARE = [
‘whitenoise.middleware.WhiteNoiseMiddleware’,
‘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’,
]
ROOT_URLCONF = ‘wedding.urls’
TEMPLATES = [
{
‘BACKEND’: ‘django.template.backends.django.DjangoTemplates’,
‘DIRS’: [‘templates’], # Add this line to include the templates directory in the project
‘APP_DIRS’: True,
‘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’,
],
},
},
]
WSGI_APPLICATION = ‘wedding.wsgi.application’
Database
Database configuration
DATABASES = {
‘default’: dj_database_url.config(
default=‘postgresql://postgres:postgres@localhost:5432/weddingdb’,
conn_max_age=600
)
}
Password validation
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’,
},
]
Internationalization
LANGUAGE_CODE = ‘en-us’
TIME_ZONE = ‘UTC’
USE_I18N = True
USE_TZ = True
Static files (CSS, JavaScript, Images)
STATIC_URL = ‘/static/’
Static files configuration
STATIC_ROOT should always be set, regardless of DEBUG mode, to avoid issues
STATIC_ROOT = BASE_DIR / ‘staticfiles’
if DEBUG:
STATICFILES_DIRS = [
BASE_DIR / “app/static”,
]
else:
STATICFILES_STORAGE = ‘whitenoise.storage.CompressedManifestStaticFilesStorage’
MEDIA_URL = ‘/media/’
MEDIA_ROOT = ‘/app/media’
DEFAULT_AUTO_FIELD = ‘django.db.models.BigAutoField’