export DJANGO_SETTINGS_MODULE on windows 7
Question: I'm trying to run a pyunit unittest that depends on django project imports.

I had to export the DJANGO_SETTINGS_MOCUDLE since it wasn't set so i ran:

    
    
    set DJANGO_SETTINGS_MODULE=C:/bobbapython/boon/cms.settings
    

Which is the path to the projectroot where the .settings folder is. I've also
tried:

    
    
    set DJANGO_SETTINGS_MODULE=C:/bobbapython/boon/cms/.settings
    

I also tried with \ instead of / with no success.

I get this error message when trying to run the script via cmd

    
    
    Traceback (most recent call last):
      File "manager/tests/test_user_api/generate_testdata.py", line 12, in <module>
        from django import db
      File "C:\Python27\lib\site-packages\django\db\__init__.py", line 11, in <module>
        if DEFAULT_DB_ALIAS not in settings.DATABASES:
      File "C:\Python27\lib\site-packages\django\utils\functional.py", line 184, in inner
        self._setup()
      File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 42, in _setup
        self._wrapped = Settings(settings_module)
      File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 95, in __init__
        raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
    ImportError: Could not import settings 'C:/bobbapython/boon/cms.settings' (Is it on sys.path?): Import by filename is not supported.
    

Any suggestions on what i might be doing wrong and how to fix it?


Answer: DJANGO_SETTINGS_MODULE is not a file path. It is a Python module reference.

'C:/bobbapython/boon' should be in your PYTHONPATH, and DJANGO_SETTINGS_MODULE
should then just be 'cms.settings'.

