diff options
| author | Tim Graham <timograham@gmail.com> | 2018-05-26 20:58:41 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-05-26 21:07:19 -0400 |
| commit | 483f5d6c4f66c8dfca5770de7b1af8aea05a5e7c (patch) | |
| tree | b3bffa86aa0fd8c906f4fd490a9b77ce32a27c89 /django | |
| parent | 39e61669e0c4299228dca751852002946ebe5d5e (diff) | |
[2.1.x] Reverted "Fixed #29324 -- Made Settings raise ImproperlyConfigured if SECRET_KEY is accessed and not set."
This reverts commit b3cffde5559c4fa97625512d7ec41a674be26076 due to
a regression and performance concerns.
Backport of 5cc81cd9eb69f5f7a711412c02039b435c393135 from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/conf/__init__.py | 11 | ||||
| -rw-r--r-- | django/conf/global_settings.py | 5 |
2 files changed, 8 insertions, 8 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py index 9b3e350a50..05c603786e 100644 --- a/django/conf/__init__.py +++ b/django/conf/__init__.py @@ -116,15 +116,15 @@ class Settings: if setting.isupper(): setting_value = getattr(mod, setting) - if setting == 'SECRET_KEY' and not setting_value: - raise ImproperlyConfigured('The SECRET_KEY setting must not be empty.') - if (setting in tuple_settings and not isinstance(setting_value, (list, tuple))): raise ImproperlyConfigured("The %s setting must be a list or a tuple. " % setting) 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('DEFAULT_CONTENT_TYPE'): warnings.warn('The DEFAULT_CONTENT_TYPE setting is deprecated.', RemovedInDjango30Warning) @@ -140,11 +140,6 @@ class Settings: os.environ['TZ'] = self.TIME_ZONE time.tzset() - def __getattr__(self, name): - if name == 'SECRET_KEY': - raise ImproperlyConfigured('The SECRET_KEY setting must be set.') - raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name)) - def is_overridden(self, setting): return setting in self._explicit_settings diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index 26fa492892..befade160f 100644 --- a/django/conf/global_settings.py +++ b/django/conf/global_settings.py @@ -256,6 +256,11 @@ ABSOLUTE_URL_OVERRIDES = {} # ] IGNORABLE_404_URLS = [] +# A secret key for this particular Django installation. Used in secret-key +# hashing algorithms. Set this in your settings, or Django will complain +# loudly. +SECRET_KEY = '' + # Default file storage mechanism that holds media. DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' |
