From d9e7372e9396eac33b3cd09f238b72e28d5f9fcb Mon Sep 17 00:00:00 2001 From: princekumarofficial Date: Wed, 21 Aug 2024 03:02:49 +0530 Subject: [PATCH] Static files fix --- messWebsite/settings.py | 5 +---- messWebsite/urls.py | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/messWebsite/settings.py b/messWebsite/settings.py index 646db3f..76b963e 100644 --- a/messWebsite/settings.py +++ b/messWebsite/settings.py @@ -182,10 +182,7 @@ # https://docs.djangoproject.com/en/4.1/howto/static-files/ STATIC_URL = "/static/" -STATICFILES_DIRS = [ - os.path.join(BASE_DIR, "static"), -] -STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") +STATIC_ROOT = BASE_DIR / 'staticfiles' # managing media CLOUDINARY_STORAGE = { "CLOUD_NAME": env("CLOUD_NAME"), diff --git a/messWebsite/urls.py b/messWebsite/urls.py index 2a7faa1..b4298e0 100644 --- a/messWebsite/urls.py +++ b/messWebsite/urls.py @@ -20,9 +20,9 @@ from allauth.socialaccount.providers.google.views import oauth2_callback, oauth2_login from django.conf import settings -from django.conf.urls.static import static from django.contrib import admin from django.urls import include, path +from django.views.static import serve urlpatterns = [ path("admin/doc/", include("django.contrib.admindocs.urls")), @@ -31,4 +31,6 @@ path("accounts/google/login/", oauth2_login, name="google_login"), path("accounts/google/login/callback/", oauth2_callback, name="google_callback"), path("", include("home.urls")), -] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + path('media//', serve, {'document_root': settings.MEDIA_ROOT}), + path('static//', serve, {'document_root': settings.STATIC_ROOT}), +]