Configure Whitenoise to serve static files in production
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 21s

This commit is contained in:
vickytechkey 2026-08-23 12:30:35 +05:30
parent d49fd41bfd
commit 53fe092d65
3 changed files with 7 additions and 0 deletions

View file

@ -83,6 +83,7 @@ jobs:
# ── 6. Run Database Migrations ─────────────────────────────────
./venv/bin/python manage.py migrate --noinput
./venv/bin/python manage.py collectstatic --noinput
# ── 7. Configure and restart Systemd service ───────────────────
sudo mv /tmp/emailservice.service /etc/systemd/system/emailservice.service

View file

@ -46,6 +46,7 @@ INSTALLED_APPS = [
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
@ -133,6 +134,10 @@ USE_TZ = True
# https://docs.djangoproject.com/en/6.1/howto/static-files/
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
# Simplified static file serving.
# https://whitenoise.readthedocs.io/en/latest/django.html#add-compression-and-caching-support
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
MEDIA_URL = 'media/'
MEDIA_ROOT = BASE_DIR / 'media'

View file

@ -13,3 +13,4 @@ six==1.17.0
sqlparse==0.6.0
urllib3==2.7.0
gunicorn==22.0.0
whitenoise==6.7.0