Reputation: 3262
I try to add multiple settings for my django project. Separate settings for devserver and production.
For this I removed my settings.py file and the new file structure would look like this:
mysite/
|-- mysite/
| |-- __init__.py
| |-- settings/
| | |-- __init__.py
| | |-- base.py
| | |-- development.py
| | |-- production.py
| |-- urls.py
| +-- wsgi.py
+-- manage.py
I filled in base.py, development.py, production.py and replaced the path to the root of the project at base.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
to ==>
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
And it working good at my local server when I start
python manage.py runserver --settings=mysite.settings.development
but when I do the same settings in production I get Internal server error. My server works for Nginx and Uwsgi.
Upvotes: 1
Views: 79
Reputation: 13057
You have done this BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
correctly.
You need to do:
In settings/__init__.py
file put the below codes.
from .production import *
try:
from .local import *
except:
pass
Now, run
python manage.py runserver
It will work fine.
Upvotes: 0