I am trying to configure my tech stack of Django
, webpack
, and reactjs
Here is my project structure:
Right now I am getting this error when I run python manage.py runserver
:
ImportError: No module named cherngloong.settings
Traceback:
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
It is being caused by settings.py
being in a different location.
I want to keep this structure of my project because I want to app
directory to handle the front end and I want the server
directory to handle the backend. How can I keep this structure but also be able to run the runserver
command?
I looked within manage.py
and I found this:
#!/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)
It seems to me that I need to change cherngloong.settings
. I tried to change this to server.cherngloong.settings
but I get the same error:
ImportError: No module named server.cherngloong.settings