title: Django Shell No module named settings
body: <p>I've deployed Django to Apache via <code>mod_wsgi</code>. Django is running fine when hosted from Apache. However, I'm trying to do some maintenance via <code>manage.py</code>, but when I try and run it, I get the error:</p>
  
  <blockquote>
    <p>Error: Could not import settings 'myproject.settings' (Is it on sys.path?): No module named settings</p>
  </blockquote>
  
  <pre><code>user@localhost:~$ cd /usr/local/myproject
  user@localhost:/usr/local/myproject$ ls
  drwxr-xr-x 2 apache apache   4096 2011-09-07 19:38 apache
  -rw-r--r-- 1 apache apache      0 2011-05-25 14:52 __init__.py
  -rw-r--r-- 1 apache apache    813 2011-09-09 16:56 manage.py
  drwxr-xr-x 6 apache apache   4096 2011-09-09 16:43 myapp
  -rw-r--r-- 1 apache apache   4992 2011-09-07 19:31 settings.py
  drwxr-xr-x 4 apache apache   4096 2011-09-08 20:32 templates
  -rw-r--r-- 1 apache apache   1210 2011-09-08 14:49 urls.py
  </code></pre>
  
  <p>Django seems to be ignoring the DJANGO_SETTINGS_MODULE environment variable.</p>
  
  <pre><code>user@localhost:~$ cd /usr/local/myproject
  user@localhost:/usr/local/myproject$ export DJANGO_SETTINGS_MODULE=settings
  user@localhost:/usr/local/myproject$ python manage.py shell
  Error: Could not import settings 'myproject.settings' (Is it on sys.path?): No module named settings
  user@localhost:/usr/local/myproject$ python
  Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
  [GCC 4.4.3] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import settings
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>Just to confirm I wasn't going crazy, I commented out everything inside manage.py except the <code>import settings</code> line, and it ran correctly.</p>
  
  <p>I've also tried setting <code>os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'</code> and <code>sys.path.append('/usr/local/myproject')</code> directly at the top of manage.py, to no avail.</p>
  
  <p>What's going on here? Why is Django using the wrong settings module name? This is driving me crazy.</p>