Skip to content

Commit

Permalink
Add whitenoise module
Browse files Browse the repository at this point in the history
  • Loading branch information
IYStoychev21 committed Jan 23, 2024
1 parent ee7955e commit 5ce645c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ uritemplate==4.1.1
urllib3==2.1.0
vine==5.1.0
wcwidth==0.2.13
whitenoise==6.6.0
17 changes: 14 additions & 3 deletions backend/valium_backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
'allauth.account',
'allauth',
Expand All @@ -49,8 +50,9 @@
]

MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down Expand Up @@ -200,6 +202,15 @@
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
SESSION_COOKIE_DOMAIN = ".valiumonline.live"
CSRF_COOKIE_DOMAIN = ".valiumonline.live"
DEBUG = False
DEBUG = False

STATIC_ROOT = BASE_DIR / "staticfiles"

STORAGES = {
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
}
}

STATIC_ROOT = BASE_DIR / "static"
STATIC_HOST = os.environ.get("VITE_BASE_URL_BACKEND")
STATIC_URL = str(STATIC_HOST) + "/static/"
4 changes: 1 addition & 3 deletions backend/valium_backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from django.conf.urls.static import static
from django.conf import settings

schema_view = get_schema_view(
openapi.Info(
Expand All @@ -39,4 +37,4 @@
path('api/v1/inbox/', include('inbox.urls')),
path('api/v1/wills/', include('wills.urls')),
path('docs/', schema_view.with_ui('swagger', cache_timeout=0)),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
]

0 comments on commit 5ce645c

Please sign in to comment.