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 2 years, 5 months ago
  2. Single Django App behind multiple Apache Proxies by chadmaine 4 years, 9 months ago
  3. Template context processor to make the settings.py values available in templates by tamizhgeek 9 months ago
  4. Using URLs for highlighting sections in menu by diverman 1 year, 6 months ago
  5. Simple Mobile Support by bahoo 1 year, 4 months ago

Comments

(Forgotten your password?)