Django - referencing different settings files from wsgi depending on server

Viewed 2028

I'm surprised I can't find an existing question related to this. Perhaps there's an obvious answer that I'm overlooking. But, let's say I have my django project named "foo". Settings for foo are defined in multiple files as encouraged by the Two Scoops book.

settings/
    local.py
    dev.py
    prod.py

Dev and prod are separate instances of the same repo both of which are served using Apache through my Webfaction account. For the dev site I want it to use settings/dev.py and for the prod site I want it to use settings/prod.py. My wsgi.py file contains the following line:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "foo.settings.prod")

This is where I get confused. How to load the dev site with foo.settings.dev instead?

Could I replace wsgi.py with multiple files, and then in each of my httpd.conf files assign WSGIScriptAlias to the correct wsgi file?

wsgi/
    dev.py
    prod.py

Thanks

3 Answers
Related