0

My django project consists of a lot of apps, libraries and middleware. I would like to run different configurations of this project on different virtual hosts (because of different use cases and needs, for example: one for users, one for M2M api, etc). From this question I understand that it should not be a problem to host this, as long as I have separate wsgi bootstrap files, but I don't understand why the following line:

os.environ['DJANGO_SETTINGS_MODULE'] = 'site1.settings'

does not cause an error with simultaneous deployments. If I have several virtual hosts with their own wsgi config files, all of which set up the DJANGO_SETTINGS_MODULE system variable, don't they overwrite each other's setting?

Does this setting get changed "just-in-time" on every request? In that case, is there a more efficient way of handling such multi-host setup?

Thanks,

Community
  • 1
  • 1
Goro
  • 9,919
  • 22
  • 74
  • 108

1 Answers1

1

The django-installations all have their own python-scope. That means that the variables of site1 are not available in site2. That is the same as two python-shells. You can not access to the others environment.

So you have two running instances of your project. One for site1 and one for site2.

I also handle my installations in this way, but I can imagine that it would be better to use only one installation and offer things like apis in a subpage. But I do not know, whether it is significant better for the performance.

blacklwhite
  • 1,888
  • 1
  • 12
  • 17
  • Yes, by default each WSGI application gets its own sub interpreter within a process. The isolation isn't always perfect but usually works. For best isolation, better to use a separate mod_wsgi daemon process group for each WSGI application by using WSGIDaemonProcess/WSGIProcessGroup in combination. – Graham Dumpleton Feb 02 '12 at 12:34