from django.contrib.sites.models import Site def location(request): location = {} current_site = Site.objects.get_current() location['site'] = current_site script_name = request.META['SCRIPT_NAME'] location['script_name'] = script_name path = request.META['PATH_INFO'] location['path'] = path url = 'http://%s%s%s' % (current_site, script_name, path) location['url'] = url return {'location': location}