title: Python Django set DJANGO_SETTINGS_MODULE when migrating source code
body: <p><strong>Task:</strong> Set up a new running environment by being provided python/Django source code and some additional details.</p>
  <p><strong>Problem:</strong> Cannot get Django-admin to validate due to missing/incorrect settings configuration
  &quot;<strong>django.core.exceptions.ImproperlyConfigured</strong> Requested setting USE_I18N, but settings are not configured. ..... &quot;</p>
  <blockquote>
  <p>You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings</p>
  </blockquote>
  <p>Env Details: Ubuntu OS, Python 2.7, Django 1.7, PostgreSQL (also Supervisor + gunicorn) Running a venv located **/home/dave/python-env/vas/**bin/activate</p>
  <p>Python sys.path</p>
  <pre><code>/usr/lib/python2.7/* (multiple defined)
  /home/dave/python-env/vas/python2.7/site-packages
  </code></pre>
  <p>So tried several methods (including #export DJANGO_SETTINGS_MODULE=project-name.settings....) with little success.</p>
  <p>How can one set the DJANGO_SETTINGS_MODULE variable?
  os.environ.setdefault() is set in wsgi (I know this is the next step)
  BUT this value is also set in /manage.py ...?</p>
  <pre><code>os.environ.setdefault(&quot;DJANGO_SETTINGS_MODULE&quot;, project_name.settings)
  </code></pre>
  <p>The directory /var/www/app/ (where the python source code is located) has several files, one of them is the project_name where the settings.py sits....
  I am new to python/django...</p>
  <p>Trying to get django-admin.py validate to validate.</p>
  <p><strong>Update:</strong> Running #python manage.py runserver runs OK. #python manage.py validate|check returns &quot;System check identified no issues (0 silenced)</p>
  <p>Running #django-admin.py check returns the error in question. &quot;You must either define DJANGO_SETTINGS_MODULE ....&quot;</p>
  <p><strong>UPDATE 2: Solution</strong>
  Turns out you don't need django-admin.py as suggested by (Alasdair) and you can use manage.py.</p>
  <p>Details - If the 'manage.py check' function returns no issues and #pip install -r requirements.txt completes within your virtual environment THEN one can run #manage.py createsuperuser</p>
  <p>I was able to use #manage.py runserver after creating a super user, and using this new user (as the database tables were empty for security reasons) I was able to log into 127.0.0.1:8000/admin. From there the models/tables were visible and using the admin functions I could create a new user + group to access the original system that was being migrated as an admin user.
  Also not that a database was required (running postgres) with db/username/pass as per settings files and a git repository (at least empty initialised) for raven...</p>
  <p>hope this helps someone coming into python.</p>