我想配置我的Django
,webpack
技術堆棧,並reactjs
用的WebPack和reactjs項目結構的Django的runserver
這裏是我的項目結構:
現在我得到我跑這個錯誤python manage.py runserver
:
ImportError: No module named cherngloong.settings
回溯:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
utility.execute()
File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/Users/bli1/Development/Django/CL/cherngloong/cherngloong/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named cherngloong.settings
它被通過settings.py
在不同的位置被引起的。
我想保留我的項目結構,因爲我想要app
目錄來處理前端,我希望server
目錄處理後端。我怎樣才能保持這種結構,但也能夠運行runserver
命令?
我看着內manage.py
,我發現這一點:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cherngloong.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
在我看來,我需要改變cherngloong.settings
。我試圖改變這server.cherngloong.settings
但我得到了同樣的錯誤:
ImportError: No module named server.cherngloong.settings
@Bjorn ahh youre – Liondancer
@Bjorn如果你回答這個問題我會接受你的回答 – Liondancer