From f9aacc3f3e4d5de9b4c5384e9afa81e302295e08 Mon Sep 17 00:00:00 2001 From: SaJH Date: Sat, 17 May 2025 15:32:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20static=20URL=20s3=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SaJH --- app/core/settings.py | 8 +++++++- app/core/urls.py | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/core/settings.py b/app/core/settings.py index 32e3cb6..2af2eb5 100644 --- a/app/core/settings.py +++ b/app/core/settings.py @@ -269,12 +269,18 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.2/howto/static-files/ STATIC_ROOT = BASE_DIR / "static" -STATIC_URL = "static/" DEFAULT_STORAGE_BACKEND = env("DJANGO_DEFAULT_STORAGE_BACKEND", default="storages.backends.s3.S3Storage") STATIC_STORAGE_BACKEND = env("DJANGO_STATIC_STORAGE_BACKEND", default="storages.backends.s3.S3Storage") STORAGE_BUCKET_NAME = f"pyconkr-backend-{API_STAGE}" + +STATIC_URL = ( + f"https://{STORAGE_BUCKET_NAME}.s3.amazonaws.com/" + if STATIC_STORAGE_BACKEND == "storages.backends.s3.S3Storage" + else "static/" +) + STORAGE_OPTIONS = ( { "bucket_name": STORAGE_BUCKET_NAME, diff --git a/app/core/urls.py b/app/core/urls.py index 942f940..da621bb 100644 --- a/app/core/urls.py +++ b/app/core/urls.py @@ -17,7 +17,6 @@ import core.health_check from django.conf import settings -from django.conf.urls.static import static from django.contrib import admin from django.urls import include, path, re_path, resolvers from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView @@ -33,7 +32,7 @@ path("admin/", admin.site.urls), # V1 API re_path("^v1/", include((v1_apis, "v1"), namespace="v1")), -] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) +] if settings.DEBUG: urlpatterns += [ From d9bf38d992729e4bffd5982fba4eb4791dabd71c Mon Sep 17 00:00:00 2001 From: SaJH Date: Sat, 17 May 2025 15:41:39 +0900 Subject: [PATCH 2/2] fix: minor Signed-off-by: SaJH --- app/core/urls.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/core/urls.py b/app/core/urls.py index da621bb..942f940 100644 --- a/app/core/urls.py +++ b/app/core/urls.py @@ -17,6 +17,7 @@ import core.health_check from django.conf import settings +from django.conf.urls.static import static from django.contrib import admin from django.urls import include, path, re_path, resolvers from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView @@ -32,7 +33,7 @@ path("admin/", admin.site.urls), # V1 API re_path("^v1/", include((v1_apis, "v1"), namespace="v1")), -] +] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) if settings.DEBUG: urlpatterns += [