title: SECRET_KEY error with Django using uWSGI
body: <p>I'm trying to run a Python 3 Django application with uWSGI, and having trouble.</p>
  
  <p>I run uWSGI as a daemon:</p>
  
  <pre><code>$ sudo service uwsgi start
  </code></pre>
  
  <p>I'm using a file like the following:
      [uwsgi]</p>
  
  <pre><code>chdir = /home/ubuntu/my_app
  module = my_app.wsgi
  # path below is to virtual environment
  home = /home/ubuntu/my_app/env 
  http = :8000
  check-static = /var/www/my_app
  daemonize = /var/log/uwsgi/my_app
  
  # process-related settings
  master = true
  processes = 10
  vacuum = true
  </code></pre>
  
  <p>And I get the following puzzling error:</p>
  
  <pre><code>mapped 800360 bytes (781 KB) for 10 cores
  *** Operational MODE: preforking ***
  Traceback (most recent call last):
    File "./titlematch_api/wsgi.py", line 14, in &lt;module&gt;
      application = get_wsgi_application()
    File "/home/ubuntu/titlematch_api/env/lib/python3.4/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
      django.setup()
    File "/home/ubuntu/titlematch_api/env/lib/python3.4/site-packages/django/__init__.py", line 17, in setup
      configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
    File "/home/ubuntu/titlematch_api/env/lib/python3.4/site-packages/django/conf/__init__.py", line 48, in __getattr__
      self._setup(name)
    File "/home/ubuntu/titlematch_api/env/lib/python3.4/site-packages/django/conf/__init__.py", line 44, in _setup
      self._wrapped = Settings(settings_module)
    File "/home/ubuntu/titlematch_api/env/lib/python3.4/site-packages/django/conf/__init__.py", line 92, in __init__
      mod = importlib.import_module(self.SETTINGS_MODULE)
    File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "./titlematch_api/settings.py", line 20, in &lt;module&gt;
      SECRET_KEY = os.environ['SECRET_KEY']
    File "/usr/lib/python3.4/os.py", line 631, in __getitem__
      raise KeyError(key) from None
  KeyError: 'SECRET_KEY'
  </code></pre>
  
  <p>I have set the <code>SECRET_KEY</code> environment variable, both for my current user, and as root, and I can successfully execute <code>os.environ['SECRET_KEY']</code> in the python shell.</p>