title: ImproperlyConfigured: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings
body: <p>I was trying to configure my Django project to deploy to Heroku. I am getting the following error and I don't really know how to fix it.</p>
  <p>Here is the <strong>full traceback</strong> and error:</p>
  <pre><code>22:46:15 web.1  | Traceback (most recent call last):
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/gunicorn/arbiter.py&quot;, line 495, in spawn_worker
  22:46:15 web.1  |     worker.init_process()
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/gunicorn/workers/base.py&quot;, line 106, in init_process
  22:46:15 web.1  |     self.wsgi = self.app.wsgi()
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/gunicorn/app/base.py&quot;, line 114, in wsgi
  22:46:15 web.1  |     self.callable = self.load()
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py&quot;, line 62, in load
  22:46:15 web.1  |     return self.load_wsgiapp()
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py&quot;, line 49, in load_wsgiapp
  22:46:15 web.1  |     return util.import_app(self.app_uri)
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/gunicorn/util.py&quot;, line 354, in import_app
  22:46:15 web.1  |     __import__(module)
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/nirla/wsgi.py&quot;, line 12, in &lt;module&gt;
  22:46:15 web.1  |     from dj_static import Cling
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/dj_static.py&quot;, line 7, in &lt;module&gt;
  22:46:15 web.1  |     from django.contrib.staticfiles.handlers import StaticFilesHandler as DebugHandler
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py&quot;, line 8, in &lt;module&gt;
  22:46:15 web.1  |     from django.contrib.staticfiles.views import serve
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/django/contrib/staticfiles/views.py&quot;, line 13, in &lt;module&gt;
  22:46:15 web.1  |     from django.views import static
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/django/views/static.py&quot;, line 96, in &lt;module&gt;
  22:46:15 web.1  |     template_translatable = ugettext_noop(&quot;Index of %(directory)s&quot;)
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/django/utils/translation/__init__.py&quot;, line 65, in gettext_noop
  22:46:15 web.1  |     return _trans.gettext_noop(message)
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/django/utils/translation/__init__.py&quot;, line 52, in __getattr__
  22:46:15 web.1  |     if settings.USE_I18N:
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/django/conf/__init__.py&quot;, line 54, in __getattr__
  22:46:15 web.1  |     self._setup(name)
  22:46:15 web.1  |   File &quot;/Users/nir/nirla/venv/lib/python2.7/site-packages/django/conf/__init__.py&quot;, line 47, in _setup
  22:46:15 web.1  |     % (desc, ENVIRONMENT_VARIABLE))
  22:46:15 web.1  | ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
  </code></pre>
  <p>Here is my <strong>wsgi.py</strong> file:</p>
  <pre><code>import os
  from django.core.wsgi import get_wsgi_application
  from dj_static import Cling
  
  os.environ.setdefault(&quot;DJANGO_SETTINGS_MODULE&quot;, &quot;nirla.settings&quot;) #nirla is the name of the project
  
  
  application = Cling(get_wsgi_application())
  </code></pre>
  <p>And in case it was relevant, my <strong>manage.py</strong> file:</p>
  <pre><code>import os
  import sys
  
      if __name__ == &quot;__main__&quot;:
          os.environ.setdefault(&quot;DJANGO_SETTINGS_MODULE&quot;, &quot;nirla.settings&quot;)
      
          from django.core.management import execute_from_command_line
      
          execute_from_command_line(sys.argv)
  </code></pre>
  <p>Can anyone seem to understand the issue here? And if so, can you be so kind as to explain what is wrong?</p>