python - Django cannot import LOCAL settings -


edit: playing around django 1.7... , python 3

i can't seem import local_settings.py settings.py file when using manage.py.

if execute settings.py file directly, local_settings.py file imported fine, without errors.

however, when run manage.py, complains not find local_settings.py module. settings.py , local_settings.py in same folder...

any ideas?

traceback (most recent call last):   file "/home/cg/webdev/riv_com/lib/python3.4/site-packages/django/conf/__init__.py", line 94, in __init__     mod = importlib.import_module(self.settings_module)   file "/usr/lib/python3.4/importlib/__init__.py", line 104, in import_module     return _bootstrap._gcd_import(name[level:], package, level)   file "<frozen importlib._bootstrap>", line 2231, in _gcd_import   file "<frozen importlib._bootstrap>", line 2214, in _find_and_load   file "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked   file "<frozen importlib._bootstrap>", line 1200, in _load_unlocked   file "<frozen importlib._bootstrap>", line 1129, in _exec   file "<frozen importlib._bootstrap>", line 1448, in exec_module   file "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed   file "/home/cg/webdev/riv_com/riv_com/riv_com/settings.py", line 79, in <module>     local_settings import * importerror: no module named 'local_settings'  during handling of above exception, exception occurred:  traceback (most recent call last):   file "./manage.py", line 10, in <module>     execute_from_command_line(sys.argv)   file "/home/cg/webdev/riv_com/lib/python3.4/site-packages/django/core/management/__init__.py", line 427, in execute_from_command_line     utility.execute()   file "/home/cg/webdev/riv_com/lib/python3.4/site-packages/django/core/management/__init__.py", line 386, in execute     settings.installed_apps   file "/home/cg/webdev/riv_com/lib/python3.4/site-packages/django/conf/__init__.py", line 46, in __getattr__     self._setup(name)   file "/home/cg/webdev/riv_com/lib/python3.4/site-packages/django/conf/__init__.py", line 42, in _setup     self._wrapped = settings(settings_module)   file "/home/cg/webdev/riv_com/lib/python3.4/site-packages/django/conf/__init__.py", line 98, in __init__     % (self.settings_module, e) importerror: not import settings 'riv_com.settings' (is on sys.path? there import error in settings file?): no module named 'local_settings' 

edit:

this error seems occur in python3.4

i've tested with:

django 1.6 + python3.4 = error
django 1.7 + python3.4 = error

django 1.6 + python2.7 = okay

python 3.4 not support implicit relative imports: from local_settings import * in python 3 absolute import , search local_settings module in sys.path, not in same directory settings.py module is. need use explicit relative import: from .local_settings import *; work in python 2.7.

reference: pep 328


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -