From a8d20bacb011eb04ebf5b7ce1c45f5f82ef25445 Mon Sep 17 00:00:00 2001 From: Quentin BEY Date: Wed, 30 Apr 2025 15:09:41 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F(back)=20use=20redis=20as=20s?= =?UTF-8?q?ession=20backend=20in=20dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to persist the session during development. Otherwise the session is reset everytime the server is restart. This behavior make developing bot a front and back feature a nigthmare, we spend our time login again and again. Shamelessly copy/pasted from @lunika 's work suitenumerique/docs@007854a --- src/backend/people/settings.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/backend/people/settings.py b/src/backend/people/settings.py index 3144633..b1e5737 100755 --- a/src/backend/people/settings.py +++ b/src/backend/people/settings.py @@ -817,6 +817,29 @@ class Development(Base): DEBUG = True SESSION_COOKIE_NAME = "people_sessionid" + SESSION_CACHE_ALIAS = "session" + + CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.dummy.DummyCache", + }, + "session": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": values.Value( + "redis://redis:6379/2", + environ_name="REDIS_URL", + environ_prefix=None, + ), + "TIMEOUT": values.IntegerValue( + 30, # timeout in seconds + environ_name="CACHES_DEFAULT_TIMEOUT", + environ_prefix=None, + ), + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + }, + }, + } # this is a dev credentials for mail provisioning API MAIL_PROVISIONING_API_CREDENTIALS = "bGFfcmVnaWU6cGFzc3dvcmQ="