Multiple Django Sites

Suppose I have two sites foo.com and bar.com. They are both located on the same server and now work with separate instances of Django and apache for its maintenance. Of course, every instance of Django eats memory.

While basically these sites are the same systems, but with different applications loaded - perhaps it is possible to somehow have, for example, one instance of Django and use several sites? Then I will save memory for one instance in a specific example.

Perhaps there are different sites with url.py files, downloaded applications, etc.? And if this is the right way?

Any advice, ideas are welcome.

Thanks Ignas

+6
source share
3 answers

Yes, of course, it is possible to have different sites with different urls.py and common applications. I had to share backend data between several sites. I just created 2 wsgi configuration files. And 2 settings files. The sites are very familiar and do not require two separate projects. This allows me to use a single django project and a backend between multiple sites. I don’t quite know, this is what you asked about, though ...

+1
source

My own research today on the same topic leads me to conclude that you most likely should only have one settings.py parameter for the Django instance / process. And there is only one MEDIA_URL and one MEDIA_ROOT in this, which means that all your projects will be in one place. And in fact, Django 1.3 has a new static file process that goes through all the tools of your individual applications and puts them in one place, because for some reason it requires it. If you are using earlier versions, I think you can do it manually.

https://docs.djangoproject.com/en/dev/howto/static-files/

+1
source

uWSGI can serve more applications from a single instance.

See “Two Pinax sites in two virtual files in two virtual hosts with one uWSGI instance” in the uWSGI examples and VirtualHosting Mode .

+1
source

Source: https://habr.com/ru/post/902794/


All Articles