Code

Ticket #10130: 10130-r9791.diff

File 10130-r9791.diff, 807 bytes (added by jcassee, 5 years ago)
Line 
1Index: django/conf/__init__.py
2===================================================================
3--- django/conf/__init__.py     (revision 9791)
4+++ django/conf/__init__.py     (working copy)
5@@ -41,6 +41,16 @@
6                 self._import_settings()
7             setattr(self._target, name, value)
8 
9+    def __delattr__(self, name):
10+        if name == '_target':
11+            # Delete directly from self.__dict__, because otherwise we'd call
12+            # __delattr__(), which would be an infinite loop.
13+            del self.__dict__['_target']
14+        else:
15+            if self._target is None:
16+                self._import_settings()
17+            delattr(self._target, name)
18+
19     def _import_settings(self):
20         """
21         Load the settings module pointed to by the environment variable. This