简体   繁体   中英

from django.db import models returns No module named mywebsite.settings

I have tried so hard to make this work but it is not working. I have read myriads of answers here in SO but it's been futile.

I installed Python 2.7 and Django 1.6.5. I have created a virtualenv , env where I created my project and app as well. The Django Server is running fine after installing MySQL-python and running manage syncdb that created all the apps in INSTALLED_APPS but if I try to from django.db import models it says:

ImportError: Could not import settings 'mywebsite.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named mywebsite.settings

I created a Path in Environment Variables in System variables. Variable name is DJANGO_SETTINGS_MODULE and its value is mywebsite.settings .

What am I doing wrong?

You can either run python manage.py runserver from the same directory as your settings.py (that is mywebsite), or you should export PYTHONPATH to have mywebsite.settings in the path by export PYTHONPATH=$PYTHONPATH:<path_to_mywebsite> (for a unix system)

For windows take a look at how to add to pythonpath in windows

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM