Skip to content

Commit a76f3f6

Browse files
authored
Add Whitenoise middleware to settings
Added Whitenoise middleware for static file handling.
1 parent 87be41e commit a76f3f6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

settings.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
from pathlib import Path
3+
BASE_DIR = Path(__file__).resolve().parent.parent
4+
5+
STATIC_URL = '/static/'
6+
STATIC_ROOT = BASE_DIR / 'staticfiles'
7+
8+
MIDDLEWARE = [
9+
'django.middleware.security.SecurityMiddleware',
10+
'whitenoise.middleware.WhiteNoiseMiddleware', # 👈 add this line
11+
'django.contrib.sessions.middleware.SessionMiddleware',
12+
'django.middleware.common.CommonMiddleware',
13+
'django.middleware.csrf.CsrfViewMiddleware',
14+
'django.contrib.auth.middleware.AuthenticationMiddleware',
15+
'django.contrib.messages.middleware.MessageMiddleware',
16+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
17+
]

0 commit comments

Comments
 (0)