Q:

Django ImportError for models.py

(Updating my question with more information.)
My django app is running fine on my dev server. 
I have a view that pulls from the database using the below line that works fine:
from myapp.models import MyTable

However, if I add the above 'from/import' to another module (see below structure, it's the module named 'problem_module.py') I'm writing where I want to pull from the sqlite3 database, I get this error. 
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'myfolder.settings' (Is it on sys.path?): No module  named myfolder.settings

I've read and tried various solutions recommended when people get this error, but I missing something because i'm unable to resolve it. 
I'm using Django 1.4 and have the lay-out as recommended. 
    mysite/
         manage.py

         mysite/
            __init__.py
            settings.py
            urls.py
            wsgi.py
         myapp/
            __init__.py
            models.py
            admin.py
            views.py

            indevelopment/
                __init__.py
                problem_module.py

A:

I figured out what was happening and why after going through the traceback carefully and looking at the django source code. Here is what happens.
When you run:
   python manage.py runserver
the environment variable gets set properly assuming you already changed this small little file or just don't pay attention to it because django 1.4 automatically configures it for you.
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
However, because this setting of os.environ is under a:
    if __name__ = "__main__"
expression, it only gets run if call that file directly, as you do with:
    python manage.py runserver
Otherwise, if you are running a file that needs that environment variable - say testing a module in Eclipse - , the os.environ needs to get set in another place (shell, etc).
All the that I got generally pointed to this but I needed the context.
But as a little adjustment (yes, not a good idea as it couples) on the source code you can also hardcode it in manually in/django/conf/__init__.py
Specifically to see where it happens, the change below works:
# in module: /django/conf/__init__.py

class LazySettings(LazyObject):
    def _setup(self):
        try:
            # Comment out the call to os.environ and hardcode in your app settings
            #    settings_module = os.environ[ENVIRONMENT_VARIABLE]
            # WARNING: bad practice to do this. ;.
            settings_module = "myapp.settings"

