from django.conf import settings
additions = {'MEDIA_URL': settings.MEDIA_URL, 'LOGOUT_URL': settings.
    LOGOUT_URL, 'BADGES': settings.BADGES, 'DJANGO_ROOT': request.META[
    'SCRIPT_NAME']}
return additions
Django - having middleware communicate with views/templates