Open GoogleCodeExporter opened 9 years ago
[deleted comment]
SOLUTION:
Django's render_to_response and template.RequestContext handle this for you.
First, make sure you enable the template auth in settings.py:
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.core.context_processors.i18n',
)
Then, in your views.py, you need:
from django.shortcuts import render_to_response
from django.template import RequestContext
.....
return render_to_response('my_template.html',
my_data_dictionary,
context_instance=RequestContext(request) )
# By adding this 3rd optional parameter to render_to_response, every
RequestContext
will contain 'user' (An auth.User instance representing the currently logged-in
user
(or an AnonymousUser instance, if the client isn't logged in).)
More at:
http://docs.djangoproject.com/en/dev/ref/templates/api/
Original comment by ken...@gmail.com
on 16 Aug 2009 at 2:39
Original issue reported on code.google.com by
ken...@gmail.com
on 12 Aug 2009 at 4:14