root/verdjnlib/context_processors/__init__.py

Revision 1, (checked in by bryan, 2 years ago)

Initial commit of verdjnlib.

Line 
1 from django.conf import settings
2
3
4 def siteroot(request):
5
6     context = {}
7
8     try:
9         context['site_url'] = settings.SITE_URL.strip()
10     except AttributeError:
11         try:
12             from django.contrib.sites.models import Site
13             context['site_url'] = Site.objects.get_current().domain
14             if context['site_url'][-1] != '/':
15                 context['site_url'] += '/'
16             if not context['site_url'].startswith('http://'):
17                 context['site_url'] = 'http://' + context['site_url']
18         except ImportError:
19             context['site_url'] = '/'
20
21     try:
22         context['media_url'] = settings.MEDIA_URL
23     except AttributeError:
24         context['media_url'] = ''
25
26     return context
Note: See TracBrowser for help on using the browser.