Answer the question
In order to leave comments, you need to log in
How to get the domain name in index.wsgi (python)?
There is a site on django, two domains are attached to it: foo.ru and bar.ru.
Each domain has its own settings.py, i.e. settings_foo.py and settings_bar.py.
In index.wsgi, you need to set different values for os.environ['DJANGO_SETTINGS_MODULE'] depending on the domain.
index.wsgi:
import os, sys
from django.core.wsgi import get_wsgi_application
sys.path.insert(0, '../news')
sys.path.insert(1, '../env/lib/python3.9/site-packages')
domain = ????????????????????????????????
if domain == 'foo.ru':
os.environ['DJANGO_SETTINGS_MODULE'] = 'news.settings_foo'
elif domain == 'bar.ru':
os.environ['DJANGO_SETTINGS_MODULE'] = 'news.settings_bar'
application = get_wsgi_application()
Answer the question
In order to leave comments, you need to log in
1 You can insert return into each condition and return, for example, a string with the name of the
domain
... receiving a request with a domain name, check if it is in the list of names and respond accordingly
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question