title: django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured
body: <p>I'm trying populate data in my modal using Faker
  but I got the error.
  here is my Code</p>
  
  <pre><code>import os
  from faker import Faker
  from first_app.models import Topic, Webpage, AccessRecord
  
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myfirst.settings')
  import django
  django.setup()
  import random
  
  fakegen = Faker()
  topics = ['search', 'Social', 'Marketplace', 'News', 'Games']
  
  
  def add_topic():
      t = Topic.objects.get_or_create(top_name=random.choice(topics))[0]
      t.save()
      return t
  
  def populate(N=5):
      for entry in range(N):
          top=add_topic()
          fake_url=fakegen.url()
          fake_date=fakegen.date()
          fake_name=fakegen.company()
  
          webpg=Webpage.objects.get_or_create(topic=top,url=fake_url,name=fake_name)[0]
  
          acc_rec=AccessRecord.objects.get_or_create(name=webpg,date=fake_date)[0]
  
  if __name__=='__main__':
      print('populating script')
      populate(30)
      print('Completed')
  </code></pre>
  
  <p>I think error is due to this line </p>
  
  <blockquote>
    <p>os.environ.setdefault</p>
  </blockquote>
  
  <p>but when I comment this line it doesn't populate data</p>
  
  <p>Below is the error</p>
  
  <blockquote>
    <p>django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJA
    NGO_SETTINGS_MODULE or call settings.configure() before accessing settings.</p>
  </blockquote>