python - Django to use different settings.py file based on subdomains -


How Django can use different settings depending on subdomain.

Whether these utilities ("django-admin", "python manage.py") can still be used if different settings connect to different databases.

    1. domain (site)
    2. Li> Current Machine

    Here I suggest:

    universal_settings.py - all the settings that you want to get everywhere (All machines, based on all domains (database settings, mail servers, etc.)

    local_settings.py - settings

    site_1.py - Settings that are specific to one of your domains - site_2.py - Settings that are available for any one of your domains. You can get this idea

    below universal_settings.py:

      import from local_settings < / Code> 

    This will override anything in the universal settings as neces Sary.

    Similarly, each site_1.py , site_2 With the .py , site_n.py settings files should start with:

      universal_settings import * to  

    Finally you set up an Apache (or NGNX, or whatever) instance for each domain And the appropriate site_n.py as the settings file for that server

    this is the method that works best for me :)


    Comments