Fix: custom storage path

This commit is contained in:
2023-08-30 16:38:28 +09:00
parent 68bec09209
commit b65481207a
6 changed files with 19 additions and 39 deletions

View File

@@ -139,12 +139,21 @@ STATIC_ROOT = BASE_DIR / 'static'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
MEDIA_ROOT = BASE_DIR / 'media'
MEDIA_URL = 'media/'
MEDIA_ROOT_FOR_SENSITIVE_FILES = BASE_DIR / 'archives'
MEDIA_URL_FOR_SENSITIVE_FILES = '/archives/'
MEDIA_ROOT = BASE_DIR / 'archives'
STORAGES = {
# ...
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
"OPTIONS": {
"location": MEDIA_ROOT,
"base_url": "/archives/",
},
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
},
}
# django-crispy-forms and crispy-bootstrap5
# https://django-crispy-forms.readthedocs.io/en/latest/

View File

@@ -1,4 +1,3 @@
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include
@@ -9,8 +8,6 @@ from drf_spectacular.views import (
)
from two_factor.urls import urlpatterns as tf_urls
from logs_collector import settings
from account.utils import AdminSiteOTPRequiredMixinRedirectSetup
@@ -57,8 +54,3 @@ urlpatterns += [
name='redoc'
),
]
if settings.DEBUG:
urlpatterns += static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
)