Repository: dynaconf/dynaconf

Issue:
Can't set custom 'settings_module' value
Hi!

I'm trying to use your (awesome looking library) for the first time and unfortunately having a lot of problems. I understand that #74 is still open and up for discussion so I wanted to explicitly set the settings module file to be sure it's read correctly, but no matter what I try it just doesn't work.

```python
from pathlib import Path

from dynaconf import LazySettings

settings = LazySettings()
settings.configure(settings_module=str(Path(__file__).parent / "settings.yaml"))
```

I added a couple of print methods to try and see what's going on - the 'patched' code:

```python
class LazySettings(LazyObject):
	# ...
    def configure(self, settings_module=None, **kwargs):
        compat_kwargs(kwargs)
        kwargs.update(self._kwargs)
        print("1", settings_module)
        self._wrapped = Settings(settings_module=settings_module, **kwargs)
        print("2", self._wrapped.SETTINGS_MODULE)

# ...

class Settings(object):
	# ...
    def __init__(self, settings_module=None, **kwargs):  # pragma: no cover
		# ...

        compat_kwargs(kwargs)
        print("3", settings_module)
        if settings_module:
            self.set('SETTINGS_MODULE', settings_module)
        for key, value in kwargs.items():
            self.set(key, value)
        # execute loaders only after setting defaults got from kwargs
        self._defaults = kwargs
        self.execute_loaders()
        print("4", self.SETTINGS_MODULE)
```

And the result of importing that settings variable:

```python
from ds import settings
1 /absolute/path/to/settings.yaml
3 /absolute/path/to/settings.yaml
4 settings.py,.secrets.py,settings.toml,settings.tml,.secrets.toml,.secrets.tml,settings.yaml,settings.yml,.secrets.yaml,.secrets.yml,settings.ini,settings.conf,settings.properties,.secrets.ini,.secrets.conf,.secrets.properties,settings.json,.secrets.json
2 settings.py,.secrets.py,settings.toml,settings.tml,.secrets.toml,.secrets.tml,settings.yaml,settings.yml,.secrets.yaml,.secrets.yml,settings.ini,settings.conf,settings.properties,.secrets.ini,.secrets.conf,.secrets.properties,settings.json,.secrets.json

```

So even though `settings_module` is correctly passed to `Settings`, it the `self.set('SETTINGS_MODULE', settings_module)` seems to disregard it completely.

I had a simillar experience when trying to set `DYNACONF_SETTINGS` instead:

```python
settings = LazySettings()
os.environ['DYNACONF_SETTINGS'] = str(Path(__file__).parent / "settings.yaml")
settings._setup()
```

```python
from ds import settings
3 None
4 settings.py,.secrets.py,settings.toml,settings.tml,.secrets.toml,.secrets.tml,settings.yaml,settings.yml,.secrets.yaml,.secrets.yml,settings.ini,settings.conf,settings.properties,.secrets.ini,.secrets.conf,.secrets.properties,settings.json,.secrets.json
```

Am I doing something wrong? It seems like a really standard use case.

Any help or pointers would be much appreciated.


Discussion:
Actually, looking through it all again I got this to work as I expected:

```python
settings = LazySettings()
os.environ['SETTINGS_MODULE_FOR_DYNACONF'] = str(Path(__file__).parent / "settings.yaml")
settings._setup()
```

But I think the (recommended?) `settings.configure(settings_module='/tmp/settings.py')` usage is still broken.
@pawelad I'll take a look later today, thanks for reporting.

Resolving patch:
diff --git a/dynaconf/base.py b/dynaconf/base.py
--- a/dynaconf/base.py
+++ b/dynaconf/base.py
@@ -166,7 +166,7 @@ def __init__(self, settings_module=None, **kwargs):  # pragma: no cover
 
         compat_kwargs(kwargs)
         if settings_module:
-            self.set('SETTINGS_MODULE', settings_module)
+            self.set('SETTINGS_MODULE_FOR_DYNACONF', settings_module)
         for key, value in kwargs.items():
             self.set(key, value)
         # execute loaders only after setting defaults got from kwargs
diff --git a/example/configure/app.py b/example/configure/app.py
new file mode 100644
--- /dev/null
+++ b/example/configure/app.py
@@ -0,0 +1,7 @@
+# coding: utf-8
+
+from dynaconf import settings
+settings.configure(settings_module='/tmp/configure_test/settings.py')
+
+assert settings.MESSAGE == 'Hello from tmp'
+print(settings.MESSAGE)  # noqa
diff --git a/example/settings_module/app.py b/example/settings_module/app.py
new file mode 100644
--- /dev/null
+++ b/example/settings_module/app.py
@@ -0,0 +1,6 @@
+# coding: utf-8
+
+from dynaconf import settings
+
+assert settings.MESSAGE == 'Hello from tmp'
+print(settings.MESSAGE)  # noqa


Test patch: