johnmic07
johnmic07

Reputation: 1265

Django ImportError: Could not import settings 'mysite.settings.local' (Is it on sys.path?): No module named settings.local

I'm setting up a site in django with multiple settings files as recommended in 2 scoops of django where settings.py is replaced with a settings directory that contains multiple settings files (local.py, etc.). My development server will run fine when I leave settings.py in the default location, but when I move it into the new settings directory I created and run the development server with:

python manage.py runserver --settings=mysite.settings.local

I get the error:

ImportError: Could not import settings 'mysite.settings.local' (Is it on sys.path?): No module named settings.local

I have added the directory to the python path and it shows up when I go into python and enter:

import sys
sys.path

I am running out of ideas. Any help would be great.

Upvotes: 2

Views: 10592

Answers (2)

Shahar
Shahar

Reputation: 2191

Python needs to have an __init__.py file in your root directory so it can consider the subfolders as importable. Please try adding __init__.py to your root directory and run python manage.py runserver in the terminal ```

Upvotes: 0

jbr3zy
jbr3zy

Reputation: 654

try touch __init__.py in your settings directory

Upvotes: 7

Related Questions