title: ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured
body: <p>I'm trying to make an SMTP live server as a separate app in django. Whenever I try to run the smtp file <code>python smtp.py</code> to listen to incoming messages and store them in models, I get ImproperlyConfigured error.</p>
  
  <p>smtp.py</p>
  
  <pre><code>import os
  import smtpd
  import asyncore
  import datetime
  from models import IncomingEmail
  from email.parser import Parser
  
  class MessageServer():
      def __call__(self, peer, mailfrom, recipients, data):
  
          email = Parser().parsestr(data)
  
          incomingDb = IncomingEmail(
                  sender=mailfrom, recipient=recipients,
                  message=data, subject=email['subject'],
                  recevied=datetime.datetime.now()
                  )
          incomingDb.save()
  
  class customSMTPServer(smtpd.SMTPServer):
      process_message = MessageServer()
  
  if __name__ ==  "__main__":
      os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello.settings")
      server = customSMTPServer(('localhost', 1025), None)
      print "Started listening at port 1025"
      try:
          asyncore.loop()
      except KeyboardInterrupt:
          server.close()
  </code></pre>
  
  <p>The project structure:</p>
  
  <pre><code>hello/
   manage.py
   hello/
    __init__.py
    settings.py
    urls.py
    wsgi.py
   smtp/
    smtp.py
    models.py
    __init__.py
   api/
    admin.py
    apps.py
    urls.py
    views.py
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environ
  ment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
  </code></pre>