From 64d02cb08fc8f67611240dc9912c29b2eb03c68e Mon Sep 17 00:00:00 2001 From: Matti Eiden Date: Tue, 15 Oct 2024 17:24:21 +0300 Subject: [PATCH] refactor: remove obsolete .django_secret The removed code is unreachable due to SECRET_KEY being always defined in settings.py --- linkedevents/settings.py | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/linkedevents/settings.py b/linkedevents/settings.py index 12a094090..3c7c3b2e5 100644 --- a/linkedevents/settings.py +++ b/linkedevents/settings.py @@ -586,37 +586,6 @@ def dummy_haystack_connection_for_lang(language_code): # shown in the browsable API INSTANCE_NAME = env("INSTANCE_NAME") -# We generate a persistent SECRET_KEY if it is not defined. Note that -# setting SECRET_KEY will override the persisted key -if "SECRET_KEY" not in locals(): - secret_file = os.path.join(BASE_DIR, ".django_secret") - try: - SECRET_KEY = open(secret_file).read().strip() - except IOError: - import random - - system_random = random.SystemRandom() - try: - SECRET_KEY = "".join( - [ - system_random.choice( - "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)" - ) - for i in range(64) - ] - ) - secret = open(secret_file, "w") - import os - - os.chmod(secret_file, 0o0600) - secret.write(SECRET_KEY) - secret.close() - except IOError: - raise Exception( - "Please create a %s file with random characters to generate your secret key!" # noqa: E501 - % secret_file - ) - # Email configuration EMAIL_HOST = env("EMAIL_HOST") EMAIL_PORT = env("EMAIL_PORT")