Get in wsgi.py apache virtualhost name

230 views Asked by At

I have apache settings:

<VirtualHost *:80>
    ServerName site1.ru
    ServerAlias site2.ru

    WSGIScriptAlias / /path/to/wsgi.py
..

I want to load some host specific settings to django settings. So, how can i get HTTP_HOST (site1.ru or site2.ru) in django settings or in wsgi.py?

2

There are 2 answers

2
drabo2005 On BEST ANSWER
in wsgi.py

import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] ='project.settings'
2
Ignacio Vazquez-Abrams On

request.META['HTTP_HOST'], same as all the other headers.