From 57b3e2144e72ae3e867d94deed0fbc2e7241c49d Mon Sep 17 00:00:00 2001 From: Patrick Mayr Date: Sun, 26 Jan 2025 13:13:09 +0100 Subject: [PATCH] update media url and context processor --- fet2020/fet2020/settings.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/fet2020/fet2020/settings.py b/fet2020/fet2020/settings.py index c82517b5..bd4cc179 100644 --- a/fet2020/fet2020/settings.py +++ b/fet2020/fet2020/settings.py @@ -106,9 +106,26 @@ EMAIL_PORT = 587 EMAIL_USE_TLS = True +# STATIC FILES +if DEBUG: + STATIC_URL = "static/" +else: + STATIC_URL = "assets/" + +# Use for collectstatic/production folder. +# --- Saving directory for production folder. +STATIC_ROOT = "assets/" + +# --- Get files from following directory for production folder. +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, "gallery/static"), + os.path.join(BASE_DIR, "static"), +] + + # FILE UPLOADS -MEDIA_ROOT = os.path.join(BASE_DIR, "files/") MEDIA_URL = "files/" +MEDIA_ROOT = os.path.join(BASE_DIR, "files") # GLOBALIZATION @@ -174,20 +191,6 @@ DEFAULT_AUTO_FIELD = "django.db.models.AutoField" SITE_ID = 1 -# STATIC FILES -STATIC_ROOT = "assets/" - -if DEBUG: - STATIC_URL = "static/" -else: - STATIC_URL = "assets/" - -STATICFILES_DIRS = [ - os.path.join(BASE_DIR, "gallery/static"), - os.path.join(BASE_DIR, "static"), -] - - # SECURITY # TODO: Security Warning # CSRF_COOKIE_SECURE = True @@ -216,6 +219,7 @@ TEMPLATES = [ "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", "django.template.context_processors.i18n", + "django.template.context_processors.media", ], }, },