Previous discussion: 
https://groups.google.com/forum/?fromgroups=#!searchin/django-developers/dynamic$20sites/django-developers/QSXLGSxy7Vk/TxgiJzz5nd8J
https://code.djangoproject.com/ticket/16983
https://code.djangoproject.com/ticket/4438

My proposal allows getting the current site based on request.get_host(), 
without changing settings.SITE_ID, and maintaining backwards compatibility.

Required code changes: http://dpaste.com/1035045/

I propose adding an optional `request` argument to 
Site.objects.get_current(), so that:

`Site.objects.get_current()` returns current `Site` based on 
settings.SITE_ID
`Site.objects.get_current(request)` returns current `Site` based on 
request.get_host()

Both conditional branches will be cached in SITE_CACHE.

The current changes I've proposed means if there is no site with domain == 
request.get_host(), it won't be able to get the current site. An 
alternative would be to fall back onto using settings.SITE_ID.

What do you think?

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to