Groups
Groups
Sign in
Groups
Groups
Django users
Conversations
About
Send feedback
Help
Accessing session variables in template with django
5,035 views
Skip to first unread message
Puneet
unread,
May 23, 2009, 1:34:19 AM
5/23/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hi All,
I am facing issue when I am trying to access session variables in
django.
I am setting the session variable something like :
request.session['cityname'] = cityname
c = RequestContext(request, {'current_date': now})
html = t.render(c)
return HttpResponse(html)
And I am trying to access it like :
{{ request.session.cityname }}
and
{{ request.cityname }}
But it does not seem to be working. Any suggestions ?
Thanks,
Puneet
Daniel Roseman
unread,
May 23, 2009, 4:39:06 AM
5/23/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
You need to enable django.core.context_processors.request in the
CONTEXT_PROCESSORS section settings.py - it's not enabled by default.
See
http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-request
--
DR.
Puneet
unread,
May 23, 2009, 11:00:55 AM
5/23/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Thanks Daniel,
Its working fine now. :)
On May 23, 1:39 am, Daniel Roseman <
roseman.dan...@googlemail.com
>
wrote:
> Seehttp://
docs.djangoproject.com/en/dev/ref/templates/api/#django-core-c.
..
> --
> DR.
Reply all
Reply to author
Forward
0 new messages