[Answered ]-Accessing variables in setting.py from templates with Django 1.4

2👍

django.core.context_processors.request only adds the request to the context, see the docs.

Write your won context processor, something like:

from django.conf import settings    

def add_site_setting(request):
  return {'site_name': settings.SITE_NAME}

Then add that function to TEMPLATE_CONTEXT_PROCESSORS in your settings.py

Also, I suggest a good habit to get into is using from django.conf import settings rather than explicitly importing your settings file.

0👍

Not sure what gave you that impression. The request context processor does exactly what it says on the tin: adds the request to the context processor. There’s nothing that says it will do anything with the SITE_NAME setting – especially as that isn’t even a standard setting.

If you want that to be added by a context processor, then you can write your own – it’ll only be two lines of code.

Leave a comment