title: Unable to fix error DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings
body: <p>Please help resolving this env issue/error. I did found many posts about resolving that error but I still couldn't fix mine. I guess I am just unable to understand it in the right way.</p>
  <pre><code>django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, 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>I have just one app in my Django project, had created using django-admin startproject. The app is added to settings.py under INSTALLED_APPS, and all other settings are set to default by Django itself which i haven't modified.</p>
  <p>I have few def in views.py working on models/forms, and those are working well.
  I also have created a new folder (myscripts) in the project (next to the app-name folder), and in that myscripts folder i have my other py scripts (other than models/forms). Executing those scripts works, I am able to import those models/forms, it does some work and adds a new entry in django db sqlite3 correctly.</p>
  <p>Further, i want to add/update execution status to the db entry (for a given pk/id) after my other scripts finishes its work.
  To achieve that, I am trying a new py script which will import models to get its objects so i can update contents in the db but that fails. (throws me above error).</p>
  <p>Based on other posts, i did try adding env variable DJANGO_SETTINGS_MODULE=my-app-name.settings, it doesn't work (i just have one app and django has it already configured -- i can see that in wsgi.py as <code>os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my-app-name.settings')</code>  ).</p>
  <p>I also tried <code>code from django.conf import settings </code>, but that also with no success.</p>
  <p>However, when I run &quot;python manage.py shell&quot; and import models and its objects they don't throw error but thorws error when i run the update py script.</p>
  <p>Please guide me where i can look for to fix the issue.</p>