From f85ec1fb89b622c165c0198ce4b77da0fe450dd3 Mon Sep 17 00:00:00 2001 From: Brian Helba Date: Fri, 9 Apr 2021 00:20:36 -0400 Subject: [PATCH 1/2] Prevent an ImproperlyConfigured warning from DEFAULT_HASHING_ALGORITHM --- configurations/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configurations/base.py b/configurations/base.py index b1bc1e9..1d7e488 100644 --- a/configurations/base.py +++ b/configurations/base.py @@ -36,6 +36,9 @@ class ConfigurationBase(type): # https://github.com/django/django/commit/226ebb17290b604ef29e82fb5c1fbac3594ac163#diff-ec2bed07bb264cb95a80f08d71a47c06R163-R170 if "PASSWORD_RESET_TIMEOUT_DAYS" in attrs and "PASSWORD_RESET_TIMEOUT" in attrs: attrs.pop("PASSWORD_RESET_TIMEOUT_DAYS") + # https://docs.djangoproject.com/en/3.1/releases/3.1/#default-hashing-algorithm-settings + if "DEFAULT_HASHING_ALGORITHM" in attrs: + attrs.pop("DEFAULT_HASHING_ALGORITHM") return super().__new__(cls, name, bases, attrs) def __repr__(self): From d715a719a4e0ec43dc3c28e56d11f74df39c8777 Mon Sep 17 00:00:00 2001 From: Brian Helba Date: Tue, 31 Aug 2021 21:28:16 -0400 Subject: [PATCH 2/2] Use a more general structure for removing deprecated settings --- configurations/base.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/configurations/base.py b/configurations/base.py index 1d7e488..24de460 100644 --- a/configurations/base.py +++ b/configurations/base.py @@ -32,13 +32,22 @@ class ConfigurationBase(type): for base in bases[::-1]: settings_vars.update(uppercase_attributes(base)) attrs = dict(settings_vars, **attrs) - # Fix ImproperlyConfigured issue introduced in Django + + deprecated_settings = { + # DEFAULT_HASHING_ALGORITHM is always deprecated, as it's a + # transitional setting + # https://docs.djangoproject.com/en/3.1/releases/3.1/#default-hashing-algorithm-settings + "DEFAULT_HASHING_ALGORITHM", + } + # PASSWORD_RESET_TIMEOUT_DAYS is deprecated in favor of + # PASSWORD_RESET_TIMEOUT in Django 3.1 # https://github.com/django/django/commit/226ebb17290b604ef29e82fb5c1fbac3594ac163#diff-ec2bed07bb264cb95a80f08d71a47c06R163-R170 - if "PASSWORD_RESET_TIMEOUT_DAYS" in attrs and "PASSWORD_RESET_TIMEOUT" in attrs: - attrs.pop("PASSWORD_RESET_TIMEOUT_DAYS") - # https://docs.djangoproject.com/en/3.1/releases/3.1/#default-hashing-algorithm-settings - if "DEFAULT_HASHING_ALGORITHM" in attrs: - attrs.pop("DEFAULT_HASHING_ALGORITHM") + if "PASSWORD_RESET_TIMEOUT" in attrs: + deprecated_settings.add("PASSWORD_RESET_TIMEOUT_DAYS") + for deprecated_setting in deprecated_settings: + if deprecated_setting in attrs: + del attrs[deprecated_setting] + return super().__new__(cls, name, bases, attrs) def __repr__(self):