Django cannot import LOCAL settings
Python 3.4 does not support implicit relative imports: from local_settings import *
in Python 3 is an absolute import and would only search for a local_settings
module in your sys.path
, but NOT in the same directory where your settings.py
module is. You need to use explicit relative import: from .local_settings import *
; this would also work in Python 2.7.
Reference: PEP 328
In settings.py
import os
SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
DEBUG = False
# delete TEMPLATE_DEBUG = DEBUG
at the bottom of settings.py
##################
# LOCAL SETTINGS #
##################
# Allow any settings to be defined in local_settings.py which should be
# ignored in your version control system allowing for settings to be
# defined per machine.
try:
from local_settings import *
except ImportError:
pass
In loacal_settings.py
# Grabs the site root setup in settings.py
# import os
# from settings import SITE_ROOT
from settings import *
DEBUG = True
TEMPLATE_DEBUG = DEBUG
# sqlite is the quick an easy development db
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(SITE_ROOT, 'djlocal.db'),
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Not used with sqlite3.
'PORT': '', # Not used with sqlite3.
}
}