1 2 3 4 5 6 7 8 9 | from django.contrib.sites.models import Site, RequestSite
def site(request):
site_info = {'protocol': request.is_secure() and 'https' or 'http'}
if Site._meta.installed:
site_info['domain'] = Site.objects.get_current().domain
else:
site_info['domain'] = RequestSite(request).domain
return site_info
|
More like this
- Absolute URL Templatetag by johnboxall 2 years, 8 months ago
- ScriptPrefixMiddleware by shellsage 2 years, 5 months ago
- media_url context variable by marchino 4 years, 10 months ago
- Mobile browser detection middleware by pavl 1 year, 9 months ago
- Context processor for django admin app_list by alexander 1 year, 12 months ago
Comments
The absolute url might also include a specific port. So that should be also included into the snippet.
#