django/django — pull request #2460 by damianmoore (2014-03-22 12:05:26+00:00)
Title: get_current_site() can retrieve Site instance from request if no SITE_ID

Previous to this commit get_current_site() would return a Site instance
if SITE_ID was configured in settings or a fake RequestSite instance
with just domain and name attributes set from the request. Whilst this
RequestSite instance is useful in some cases, it doesn't have a pk so no
other instances can be saved against it as a foreign key.

The problem became apparent when I tried to use django-cms with
multiple sites in a single Django instance. Pages need to be saved with
a Site as a foreign key. The only work-around seems to be adding some
custom middleware to change settings.SITE_ID based on the request.

I feel this issue causes a lot of frustration because people expect the
sites framework to act differently and the solution is very hacky. Here
are some examples of people trying to work around this:

https://groups.google.com/forum/#!topic/django-cms/jQNWVos9vg8
http://blog.uysrc.com/2011/03/23/serving-multiple-sites-with-django/
https://groups.google.com/forum/#!topic/django-users/yplycyyD8ZE
http://stackoverflow.com/questions/18845883/multiple-sites-on-django
http://sandbox.effbot.org/zone/django-multihost.htm