Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #18824 -- Allow deleting a setting from overriden settings

  • Loading branch information...
commit 22f85b9057825b5b4139abf5fd7e8c4ba0d16981 1 parent cc9b767
@claudep claudep authored
View
11 django/conf/__init__.py
@@ -152,11 +152,22 @@ def __init__(self, default_settings):
Requests for configuration variables not in this class are satisfied
from the module specified in default_settings (if possible).
"""
+ self.__dict__['_deleted'] = set()
self.default_settings = default_settings
def __getattr__(self, name):
+ if name in self._deleted:
+ raise AttributeError
return getattr(self.default_settings, name)
+ def __setattr__(self, name, value):
+ self._deleted.discard(name)
+ return super(UserSettingsHolder, self).__setattr__(name, value)
+
+ def __delattr__(self, name):
+ self._deleted.add(name)
+ return super(UserSettingsHolder, self).__delattr__(name)
+
def __dir__(self):
return list(self.__dict__) + dir(self.default_settings)
View
10 tests/regressiontests/settings_tests/tests.py
@@ -148,6 +148,16 @@ def test_settings_delete(self):
def test_settings_delete_wrapped(self):
self.assertRaises(TypeError, delattr, settings, '_wrapped')
+ def test_override_settings_delete(self):
+ """
+ Allow deletion of a setting in an overriden settings set (#18824)
+ """
+ previous_i18n = settings.USE_I18N
+ with self.settings(USE_I18N=False):
+ del settings.USE_I18N
+ self.assertRaises(AttributeError, getattr, settings, 'USE_I18N')
+ self.assertEqual(settings.USE_I18N, previous_i18n)
+
def test_allowed_include_roots_string(self):
"""
ALLOWED_INCLUDE_ROOTS is not allowed to be incorrectly set to a string
Please sign in to comment.
Something went wrong with that request. Please try again.