I have a problem with DJANGO_SETTINGS_MODULE. I use Pycharm and in the project settings -> Django support, everything is installed and enabled. However, I get the following error when trying to import into models.py:
from django.db import models C:\Python27\python.exe C:/Users/Grimbo/PycharmProjects/Muspy/poll/models.py Traceback (most recent call last): File "C:/Users/Grimbo/PycharmProjects/Mus/poll/models.py", line 1, in <module> from django.db import models 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 40, in _setup raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE) ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
print (sys.path):
['C:\\Program Files (x86)\\JetBrains\\PyCharm 2.6.3\\helpers\\pydev', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Users\\Grimbo\\PycharmProjects\\Mus']
Does anyone have any idea what's wrong?
source share