Hi, On 11/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I am wondering if there is a way to access request data and session object > directly from Django templates, in the same way as {{ user }} for instance. > I must admit I'm a bit lost with template context processors and so on...
You need to activate the "django.core.context_processors.request" context processor. To do that you should add the following to your settings.py file: TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.auth', 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.request', ) Then, to actually have your context processors activated during a template rendering, you must pass a RequestContext as the context for your template. In other words, when you are returning a render_to_response() in your view you should do it like this: def my_view(request): # do your stuff.... .... return render_to_response('my_template.html', my_data, context_instance=RequestContext(request) ) Take a look at the documentation here: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext Hope it helps. Regards, Jorge --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---