location context_processor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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}

More like this

  1. match filter by gsf0 3 years, 10 months ago
  2. Using URLs for highlighting sections in menu by diverman 2 years, 10 months ago
  3. Single Django App behind multiple Apache Proxies by chadmaine 6 years, 1 month ago
  4. Simple Mobile Support by bahoo 2 years, 8 months ago
  5. Add site info to request context by bthomas 4 years, 7 months ago

Comments

(Forgotten your password?)