Skip to content

Commit

Permalink
added a context processor to expose the current site
Browse files Browse the repository at this point in the history
  • Loading branch information
sontek committed Oct 31, 2010
1 parent c0e3388 commit 8b31b6d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tekextensions/context_processors.py
@@ -1,4 +1,18 @@
from django.conf import settings from django.conf import settings
from django.contrib.sites.models import Site, RequestSite


def admin_media_prefix(request): def admin_media_prefix(request):
return {'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX } return {'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX }

def current_site(request):
'''
A context processor to add the "current_site" to the current Context
'''
context_name = 'CURRENT_SITE'

try:
current_site = Site.objects.get_current()
return { name: current_site, }
except Site.DoesNotExist:
# always return a dict, no matter what!
return {name: RequestSite(request)}

0 comments on commit 8b31b6d

Please sign in to comment.