0
當我--settings
開關運行django-admin
,它失敗:如何告訴django-admin使用哪個設置模塊?
(env) $ django-admin help --settings=myapp.settings
Traceback (most recent call last):
File "/srv/http/myapp/env/bin/django-admin", line 11, in <module>
sys.exit(execute_from_command_line())
File "/srv/http/myapp/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/srv/http/myapp/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 316, in execute
settings.INSTALLED_APPS
File "/srv/http/myapp/env/lib/python3.5/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/srv/http/myapp/env/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/srv/http/myapp/env/lib/python3.5/site-packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'myapp'
(env) $ ls myapp/settings.py
myapp/settings.py
但manage.py
工作得很好。爲了說清楚,我想爲開發環境增加settings.py
。
另外,從這個腳本導入設置:
#!/usr/bin/env python
import myapp.settings
工作過。