﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17005	Add CurrentSiteMiddleware to set the current site on the request	jordan@…	chrismedrela	"I end up doing something like the following all over my code:


{{{
from django.contrib.sites.models import Site

def my_view(request, template_name=""foo.html""):
    site = Site.objects.get_current()
    ...
    return render(request, template_name, locals())

}}}

Seems like it would save time (and possibly reduce database requests, depending on where else in the application the Site object is being used) if `django.contrib.sites.middleware.SiteMiddleware` was added, which either set `request.site` to `Site.objects.get_current()` or added `site` or `current_site` to the `RequestContext`

I just did a search for ""Site.objects.get_current"" in one of my web apps and came up with 26 hits. There's really no reason to have to write out that code so many times. It should just be present as a variable somewhere."	New feature	closed	contrib.sites		Normal	fixed		krzysiumed@…	Ready for checkin	1	0	0	0	0	0
