fix: cache busting css and whitenoise for docker static files
This commit is contained in:
@@ -55,6 +55,7 @@ INSTALLED_APPS = [
|
|||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
with open('config/settings.py', 'r') as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
middleware = """MIDDLEWARE = [
|
||||||
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||||
|
"""
|
||||||
|
content = re.sub(r"MIDDLEWARE = \[\n\s+'django\.middleware\.security\.SecurityMiddleware',\n", middleware, content)
|
||||||
|
|
||||||
|
static_root = """STATIC_URL = 'static/'
|
||||||
|
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||||
|
STATICFILES_DIRS = [BASE_DIR / 'static']
|
||||||
|
"""
|
||||||
|
content = re.sub(r"STATIC_URL = 'static/'\n", static_root, content)
|
||||||
|
|
||||||
|
with open('config/settings.py', 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
|
with open('requirements.txt', 'a') as f:
|
||||||
|
f.write('\nwhitenoise==6.7.0\n')
|
||||||
@@ -50,3 +50,5 @@ vine==5.1.0
|
|||||||
wcwidth==0.8.3
|
wcwidth==0.8.3
|
||||||
wheel==0.42.0
|
wheel==0.42.0
|
||||||
zope.interface==8.5
|
zope.interface==8.5
|
||||||
|
|
||||||
|
whitenoise==6.7.0
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
<script src="https://unpkg.com/lucide@latest"></script>
|
<script src="https://unpkg.com/lucide@latest"></script>
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||||
<link rel="stylesheet" href="{% static 'css/style.css' %}?v=2.1">
|
<link rel="stylesheet" href="{% static 'css/style.css' %}?v=3.0">
|
||||||
<meta name="csrf-token" content="{{ csrf_token }}">
|
<meta name="csrf-token" content="{{ csrf_token }}">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user