From c82301a2cf28b7904309903fc7f1ac8df061e40a Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:21:03 +0200 Subject: [PATCH 01/13] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index ceeba6c2e..001ffa8e7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ django>=4.2,<5.0 gunicorn>=20.0,<21.0 dj-database-url>=2.0,<3.0 whitenoise[brotli]>=6.0,<7.0 +redis-py>=3.0.0 # Uncomment these lines to use a Postgres database. Both are needed, since in production # (which uses Linux) we want to install from source, so that security updates from the From a06251da54cf740e6b9f688bfdf1e35ea96abc9b Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:21:57 +0200 Subject: [PATCH 02/13] Update settings.py --- gettingstarted/settings.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gettingstarted/settings.py b/gettingstarted/settings.py index f075182b9..cc7cfbb6f 100644 --- a/gettingstarted/settings.py +++ b/gettingstarted/settings.py @@ -23,6 +23,16 @@ # Before using your Heroku app in production, make sure to review Django's deployment checklist: # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ +CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.redis.RedisCache", + "LOCATION": os.environ.get('REDIS_URL'), + "OPTIONS": { + "ssl_cert_reqs": None + } + } +} + # Django requires a unique secret key for each Django app, that is used by several of its # security features. To simplify initial setup (without hardcoding the secret in the source # code) we set this to a random value every time the app starts. However, this will mean many From 96820ad31d40397c3f22ee2c6444ff20dee8d0f3 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:24:00 +0200 Subject: [PATCH 03/13] Update requirements.txt --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 001ffa8e7..38f4155a6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,5 +9,5 @@ redis-py>=3.0.0 # underlying Heroku stack image are picked up automatically, thanks to dynamic linking. # On other platforms/in development, the precompiled binary package is used instead, to # speed up installation and avoid errors from missing libraries/headers. -#psycopg; sys_platform == "linux" -#psycopg[binary]; sys_platform != "linux" +psycopg; sys_platform == "linux" +psycopg[binary]; sys_platform != "linux" From e336c642bd19a421b1a8dc53c51d51edb7f8052c Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:25:09 +0200 Subject: [PATCH 04/13] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 38f4155a6..72c962557 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ django>=4.2,<5.0 gunicorn>=20.0,<21.0 dj-database-url>=2.0,<3.0 whitenoise[brotli]>=6.0,<7.0 -redis-py>=3.0.0 +redis>=3.0.0 # Uncomment these lines to use a Postgres database. Both are needed, since in production # (which uses Linux) we want to install from source, so that security updates from the From d190fd6a306ea7be343e79d669163f1d3ed09529 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:26:45 +0200 Subject: [PATCH 05/13] Update settings.py --- gettingstarted/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gettingstarted/settings.py b/gettingstarted/settings.py index cc7cfbb6f..da051c271 100644 --- a/gettingstarted/settings.py +++ b/gettingstarted/settings.py @@ -26,7 +26,7 @@ CACHES = { "default": { "BACKEND": "django.core.cache.backends.redis.RedisCache", - "LOCATION": os.environ.get('REDIS_URL'), + "LOCATION": os.environ.get('REDIS_TLS_URL'), "OPTIONS": { "ssl_cert_reqs": None } From aa73a821ab21cee4ea88bf09f89c01a219a17ae1 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:37:10 +0200 Subject: [PATCH 06/13] Update index.html --- hello/templates/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/hello/templates/index.html b/hello/templates/index.html index 55951ccc2..4104c0c4e 100644 --- a/hello/templates/index.html +++ b/hello/templates/index.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load cache %} {% block content %} From c8d6611089ac318533649becf3386b06d8874484 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:37:50 +0200 Subject: [PATCH 07/13] Update index.html --- hello/templates/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hello/templates/index.html b/hello/templates/index.html index 4104c0c4e..43171a089 100644 --- a/hello/templates/index.html +++ b/hello/templates/index.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load static %} {% load cache %} +{% cache 500 recipe %} {% block content %} @@ -57,3 +58,4 @@

Helpful Links

{% endblock %} +{% endcache %} From 1fd48e113422f8dc25f769eea84230f84a71ae31 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:41:48 +0200 Subject: [PATCH 08/13] Update views.py --- hello/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hello/views.py b/hello/views.py index bd7a34b00..5f125cdfd 100644 --- a/hello/views.py +++ b/hello/views.py @@ -3,8 +3,9 @@ from .models import Greeting # Create your views here. +from django.views.decorators.cache import cache_page - +@cache_page(60 * 15) def index(request): return render(request, "index.html") From a29572cfa42d2fb4089165ebb5d6c44231d3c091 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:42:58 +0200 Subject: [PATCH 09/13] Update settings.py --- gettingstarted/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gettingstarted/settings.py b/gettingstarted/settings.py index da051c271..bf19cb319 100644 --- a/gettingstarted/settings.py +++ b/gettingstarted/settings.py @@ -28,7 +28,7 @@ "BACKEND": "django.core.cache.backends.redis.RedisCache", "LOCATION": os.environ.get('REDIS_TLS_URL'), "OPTIONS": { - "ssl_cert_reqs": None + "ssl_cert_reqs": "require" } } } From a457e5e8dbcb42d7902e09739e16806c5af12274 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:46:50 +0200 Subject: [PATCH 10/13] Update views.py --- hello/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hello/views.py b/hello/views.py index 5f125cdfd..49a3d9b97 100644 --- a/hello/views.py +++ b/hello/views.py @@ -7,7 +7,11 @@ @cache_page(60 * 15) def index(request): - return render(request, "index.html") + try: + return render(request, "index.html") + except Exception as e: + print(e) + def db(request): From 723f41af360841d47832b4cc5036848ef6d8c0d1 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:50:45 +0200 Subject: [PATCH 11/13] Update views.py --- hello/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hello/views.py b/hello/views.py index 49a3d9b97..fc513ea1a 100644 --- a/hello/views.py +++ b/hello/views.py @@ -10,7 +10,7 @@ def index(request): try: return render(request, "index.html") except Exception as e: - print(e) + return render(request, e) From ca54745242efd8bfe14fc01e371e32aa13e2edb9 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:57:04 +0200 Subject: [PATCH 12/13] Update settings.py --- gettingstarted/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gettingstarted/settings.py b/gettingstarted/settings.py index bf19cb319..0fa682688 100644 --- a/gettingstarted/settings.py +++ b/gettingstarted/settings.py @@ -53,6 +53,7 @@ IS_HEROKU_APP = "DYNO" in os.environ and not "CI" in os.environ # SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True if not IS_HEROKU_APP: DEBUG = True From d68ee6f6e00f697b458706b56b6c93ac85d11308 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 27 Jun 2023 20:57:52 +0200 Subject: [PATCH 13/13] Update settings.py --- gettingstarted/settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gettingstarted/settings.py b/gettingstarted/settings.py index 0fa682688..059ee2a38 100644 --- a/gettingstarted/settings.py +++ b/gettingstarted/settings.py @@ -28,7 +28,6 @@ "BACKEND": "django.core.cache.backends.redis.RedisCache", "LOCATION": os.environ.get('REDIS_TLS_URL'), "OPTIONS": { - "ssl_cert_reqs": "require" } } }