Search code examples
djangorequest

django request in template


I've enabled the Django request processor

TEMPLATE_PROCESSORS = (
    "django.core.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.request",
)

Still I don't have to request variable available in templates. I've to manually pass it. Using Django 1.0.2. Everywhere on web it seems it's only about enabled request processor.

Also I am using RequestContext as:

 return render_to_response(
    'profile.html',
    {
        'persons':Person.objects.all(),
        'person':Person.objects.get(id=id),
         'request':request,
    },
    context_instance=RequestContext(request)
)

No luck.

ohh darn the new name for that is TEMPLATE_CONTEXT_PROCESSORS


Solution

  • settings.py:

    TEMPLATE_CONTEXT_PROCESSORS = (
      # ...
      'django.core.context_processors.request',
      # ...
    )