Reputation: 43
Alright, so I've been wrestling with this problem for a good two hours now.
I want to use a settings module, local.py, when I run my server locally via this command:
$ python manage.py runserver --settings=mysite.settings.local
However, I see this error when I try to do this:
ImportError: Could not import settings 'mysite.settings.local' (Is it on sys.path?): No module named base
This is how my directory is laid out:
├── manage.py
├── media
├── myapp
│ ├── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
└── mysite
├── __init__.py
├── __init__.pyc
├── settings
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── local.py
│ └── local.pyc
├── urls.py
└── wsgi.py
Similar questions have been asked, but their solutions have not worked for me.
One suggestion was to include an initialization file in the settings folder, but, as you can see, this is what I have already done.
Need a hand here!
Upvotes: 1
Views: 120
Reputation: 15484
It seems like the local.py module imports from base.py, you probably have something like:
from base import *
at the top of your local settings.
But the base.py settings module is not there, hence the error.
Upvotes: 1
Reputation: 1927
It looks like that django is not finding "mysite.settings.local" package because it is not in your PYTHONPATH
.
You have to add sys.path in your manage.py file, following should work for you :-
sys.path.append(os.path.dirname(os.path.abspath(
__file__
)))
Upvotes: 1