Django settings module not found
<h1>background</h1>

<p>I'm trying to split my settings by environment by following <a href="https://stackoverflow.com/a/15325966/766570">these instructions</a>.</p>

<p>Now I would like to simply run my test command like so:</p>

<pre><code>./run ./manage.py test --settings=bx.settings.local
</code></pre>

<p>currently the following line</p>

<pre><code>os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bx.settings")
</code></pre>

<p>is available in these files</p>

<pre><code>manage.py
wsgi.py
</code></pre>

<p>and so i removed it (since it's supposed to be read from the command line instead).</p>

<p>I also created a <code>settings</code> folder inside my <code>bx</code> app and added the files</p>

<pre><code>__init__.py
base.py
local.py
</code></pre>

<p>to it. 
<hr></p>

<h1>notes</h1>

<p>note: the <code>run</code> file is this:</p>

<pre><code>#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &amp;&amp; pwd )"
docker run \
  --env "PATH=/beneple/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
  --link beneple_db:db \
  -v $DIR:/beneple \
  -t -i --rm \
  beneple/beneple \
  $@
</code></pre>

<p><hr></p>

<h1>problem</h1>

<p>when i run the command </p>

<pre><code>./run ./manage.py test --settings=bx.settings.local
</code></pre>

<p>I get this error</p>

<pre><code>  File "/beneple/bx/org/serializers.py", line 10, in &lt;module&gt;
    from bx.settings import DOMAIN
ImportError: cannot import name DOMAIN
</code></pre>

<p>in serializers.py:10, we got this</p>

<pre><code>from bx.settings import DOMAIN
</code></pre>

<p>so i replaced <code>bx.settings</code> with </p>

<pre><code>from django.conf import settings
from settings import DOMAIN
</code></pre>

<p>and instead i got this error:</p>

<pre><code>  File "/beneple/bx/org/serializers.py", line 12, in &lt;module&gt;
    from settings import DOMAIN
ImportError: No module named settings
</code></pre>

<hr>

<h1>debugging</h1>

<p>the weird part is that if i put a breakpoint after <code>from django.conf import settings</code>, and type the following:</p>

<pre><code>ipdb&gt; print(settings)
&lt;Settings "bx.settings.local"&gt;
ipdb&gt; settings.DOMAIN
'http://localhost:8000'
</code></pre>

<p>I'm confused why it's not recognizing settings here as a module?</p>

<hr>

<h1>update</h1>

<p>I noticed that my templates directory changed. In my settings file I have</p>

<pre><code>BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
..
TEMPLATES = [{
    'DIRS': [os.path.join(BASE_DIR, 'templates')],..
</code></pre>

<p>However notice the difference in the value of <code>settings.TEMPLATES[0]['DIRS']
</code> between the old way and new way:</p>

<p><em>old way</em>:</p>

<pre><code>os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bx.settings")
['/beneple/templates']
</code></pre>

<p><em>new way</em>:</p>

<pre><code>./run ./manage.py test --settings=bx.settings.local
['/beneple/bx/templates']
</code></pre>

<p>why is this the case? and how do I (programmatically) make the new way output the same result as the old one?</p>