"site framework" on a single instance of django

I want to serve specialized RSS feeds on a different subdomain from the rest of the site.

Is it possible to use the site structure to use different urls.py and settings.py files in the same django instance . or I need to configure two apache locations and just set the various settings.py files in apache conf.

The reason I need to install two urls.py files is to avoid duplicate content. I do not want the main site to be available on rss.example.com, and I do not want the specialized channels available on example.com

Serving them from a single instance of django would be ideal, because we are on a shared hosting with limited memory, and it seems that such a waste has an open instance that only serves rss.

edit . I came to the conclusion that for several instances with separate urls.py files it will be easier for me ... but I found this article describing how to do this using one instance:

http://effbot.org/zone/django-multihost.htm

Solution: Django tupperware

In the end, I wrote a structure to run multiple copies of the site in one instance of django.

The main idea is to change the SITE_ID setting on the fly for each request and load alternative settings from the database. It does this based on the domain and by default uses SITE_ID = 1 (when it cannot find anything)

All settings in the settings.py file act as default values, which are overridden by the parameters stored in the database for the current site.

It works very well :) and it works in http://rootbuzz.com mode

+6
django apache settings rss
source share
2 answers

With Django's margin, you must have a unique settings.py for each site ... because SITE_ID is defined in settings.py and is the key for which the site is processing this request.

In other words, SITE_ID is global for your instance, and therefore you need an instance for each site.

You can have generic urls.py if you want, because nothing prevents you from using the same ROOT_URLCONF in all settings.py files on your site ... or you may have a different one for each site. In this case, you would like to include secondary URLs so that you don’t repeat yourself for any shared URLs.

There are at least two methods that you can try to execute from a single instance:

  • Use apache + mod_wsgi and use WSGIApplicationGroup and / or WSGIProcessGroup . I never needed them before, so I can’t be sure that they will work the way you want, but no matter what, you can definitely use mod_wsgi in daemon mode to significantly improve your memory size.

  • You can play with Django middleware to reject / allow URLs based on the host name of the request (see HttpRequest.get_host () in the Django docs). For that matter, although it will be a small performance hit, you can put the decorator on all your looks that check the incoming host.

+10
source share

FYI - I released django-dynamicites, which may be useful with this problem - https://bitbucket.org/uysrc/django-dynamicsites/src

+3
source share

All Articles