summaryrefslogtreecommitdiff
path: root/django/conf/__init__.py
diff options
context:
space:
mode:
authorFlorian Apolloner <apollo13@users.noreply.github.com>2020-07-29 09:06:54 +0200
committerGitHub <noreply@github.com>2020-07-29 09:06:54 +0200
commit948a874425e7d999950a8fa3b6598d9e34a4b861 (patch)
treebe16c39b7ab501df06d55d0770b02f120d51b6b8 /django/conf/__init__.py
parent9c9a3fe1180fc92fbd4c3302dbe0b3e083bf0381 (diff)
Fixed #29324 -- Made SECRET_KEY validation lazy (on first access).
Diffstat (limited to 'django/conf/__init__.py')
-rw-r--r--django/conf/__init__.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index 3bfd8ea4a1..72a9c5f504 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -81,6 +81,8 @@ class LazySettings(LazyObject):
# This is done here for performance reasons so the modified value is cached.
if name in {'MEDIA_URL', 'STATIC_URL'} and val is not None:
val = self._add_script_prefix(val)
+ elif name == 'SECRET_KEY' and not val:
+ raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
self.__dict__[name] = val
return val
@@ -184,9 +186,6 @@ class Settings:
setattr(self, setting, setting_value)
self._explicit_settings.add(setting)
- if not self.SECRET_KEY:
- raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
-
if self.is_overridden('PASSWORD_RESET_TIMEOUT_DAYS'):
if self.is_overridden('PASSWORD_RESET_TIMEOUT'):
raise ImproperlyConfigured(