Answer the question
In order to leave comments, you need to log in
Setting up django wsgi.py for multiple servers?
There is a configured server on Ubuntu18, nginx, uwsgi (I'll call it stage)
In Django, the settings (settings.py) are separated separately for development, staging.
base.py
ALLOWED_HOSTS = ['127.0.0.1']
development.py
from .base import *
DEBUG = True
from .base import *
ALLOWED_HOSTS += 'staging.site.com'
DEBUG = False
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'solution_project.settings.staging')
application = get_wsgi_application()
<code>from .base import *
ALLOWED_HOSTS += 'test.site.com'
DEBUG = False</code>
Answer the question
In order to leave comments, you need to log in
I've been doing this for a long time, it's terribly inconvenient. It is better to have the same code for everything, and make differences through environment variables, for example
DEBUG = os.environ.get('PROJECT_NAME_DJANGO_DEBUG')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question