Take the 2-minute tour ×

Let's imagine I have two sites foo.com and bar.com. They both are on the same server and now running separate Django instances and apache to serve it. Of course each Django instance eats the memory.

While mainly those sites are the same systems, but with different apps loaded - maybe it is possible somehow to have for example one Django instance running and have multiple sites using it? Then I will save memory for the one instance in a particular example.

It is possible to have different sites with their url.py files, loaded apps and so on? And if this is the right way to go?

Any tips, ideas are welcome.

Thanks, Ignas

share|improve this question
Have you already investigated the sites framework? docs.djangoproject.com/en/dev/ref/contrib/sites –  Jordan Nov 30 '11 at 22:56
A little, but also wanted to see what guys will suggest, then simply I will know the direction to go. Thanks! –  Ignas Butėnas Dec 1 '11 at 9:41

3 Answers 3

Yes it is definitely possible to have different sites with different urls.py and shared apps. I had to share a backend data between multiple sites. I just created 2 wsgi config files. And 2 settings files. The sites are very smiliar and didn't warrant two seperate projects. This allows me to use one django project and backend between multiple sites. I don't quite know if this is what you were asking though...

share|improve this answer
Sounds like you're still running a seperate server process for each Django site. and Django typically forces multiple apps to share the same DB (or makes it somewhat difficult to do otherwise.) The question is can you have completely seperate Django projects using different settings.py and different DB's all utilize the same instance of Django running in one process. –  Mark Nov 30 '11 at 22:47
This is also nice answer, but yes, would be great to know if it's possible to have separate Databases also for each project. But I'm starting to doubt about it :) For the almost the same projects I think this solution mentioned here should work nice. –  Ignas Butėnas Dec 1 '11 at 9:43

My own research today on the same topic leads me to the conclusion that you'll most likely have to have only one settings.py per Django instance/process. And the sticking point there is only one MEDIA_URL and one MEDIA_ROOT, which means all your projects media will have to be in the same location. And actually Django 1.3 has a new static file process that just goes through all the media of your seperate apps and puts them in one spot because for some reason it demands that. If you're using earlier versions I guess you can do it by hand.


share|improve this answer
thanks for the answer, will try to dig a little bit deeper. –  Ignas Butėnas Dec 1 '11 at 9:44

uWSGI can serve more applications from one instance.

See "Two Pinax site in two virtualenv in two virtualhost with only one uWSGI instance" in uWSGI examples and VirtualHosting Mode.

share|improve this answer
Yeah, if anything is going to succeed here, it's uwsgi. That's what I use, and it's ridiculously flexible and feature-rich. –  Jordan Dec 1 '11 at 19:19

Your Answer


