title: "Apps aren't loaded yet" and "django.core.exceptions.ImproperlyConfigured" in Django?
body: <p><a href="https://i.stack.imgur.com/QJdu6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QJdu6.png" alt="enter image description here"></a></p>
  
  <p>This is the directory structure of my Django project. When I am running python code of importing a model:<code>from scraping.models import LinkVendorStandard</code> from the file "framework_product_processing.py" it throws this exception:</p>
  
  <p><strong>django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.</strong>  </p>
  
  <p>When I add this code:
  <code>
  import django
  django.setup()</code></p>
  
  <p>to initialize the django project settings, I get this exception: <strong>django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.</strong></p>
  
  <p>I have the following 2 questions about this behavior:</p>
  
  <ol>
  <li>The file:"framework_product_process.py" in the django project structure is at the same level as "views.py" which can access model without having to setup the Django project.If this file is accessible from the same python path as that of view then why <strong>django.core.exceptions.ImproperlyConfigured</strong>?</li>
  <li>Even after adding <code>import django;django.setup()</code> code why I get <strong>django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.</strong>?</li>
  </ol>
  
  <p>Can anyone please explain?</p>
  
  <p><strong>Update</strong>:<a href="https://i.stack.imgur.com/Hvbw5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Hvbw5.png" alt="enter image description here"></a>
  The file "framework_prodcut_processing.py" runs without any errors when I move it to a non_app python directory. non_app is not a Django app.</p>