From 26c755aa47a839504ed934edd6af88baadc290e4 Mon Sep 17 00:00:00 2001
From: atla8167 <athanasio.lakes@dsv.su.se>
Date: Mon, 9 Dec 2024 17:56:57 +0200
Subject: [PATCH] Deploy changes

---
 extremum_web/settings.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/extremum_web/settings.py b/extremum_web/settings.py
index 018dd5dda..df674f711 100755
--- a/extremum_web/settings.py
+++ b/extremum_web/settings.py
@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/5.0/ref/settings/
 
 import os
 from pathlib import Path
+import dj_database_url
 
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
 BASE_DIR = Path(__file__).resolve().parent.parent
@@ -32,8 +33,15 @@ ALLOWED_HOSTS = ['127.0.0.1']
 
 DEBUG_PROPAGATE_EXCEPTIONS = True
 
-# Application definition
 
+SECURE_HSTS_SECONDS = 31536000  # One year
+SECURE_HSTS_INCLUDE_SUBDOMAINS = True
+SECURE_HSTS_PRELOAD = True
+SECURE_SSL_REDIRECT = True
+SESSION_COOKIE_SECURE = True
+CSRF_COOKIE_SECURE = True
+
+# Application definition
 INSTALLED_APPS = [
     "django.contrib.admin",
     "django.contrib.auth",
@@ -90,6 +98,12 @@ DATABASES = {
 }
 
 
+if 'DATABASE_URL' in os.environ:
+    DATABASES['default'] = dj_database_url.config(
+        conn_max_age=500,
+        conn_health_checks=True,
+    )
+
 # Password validation
 # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators