You need to add an entry in your settings.py for
TEMPLATE_CONTEXT_PROCESSORS, which will basically point to a function
which will put your data in a variable accessible to your template.
I basically have a variable that stores my site root url, so in a
utility file I have, I defined this function:
def siteroot(request):
return "someurl"
Then in my settings.py I have a line:
TEMPLATE_CONTEXT_PROCESSORS =
('myproject.myapp.myutilfile.siteroot',"django.core.context_processors.request",)
Now in my template, I can access the variable by saying {{ siteroot }}
On Jun 12, 9:27 am, Dushyant Sharma <[EMAIL PROTECTED]> wrote:
> i am building single page for logged in users and anonymous users
> where i can use uid for logged in users and show specific things to
> them and for this i want to use session variable in template. i am
> trying request.session.uid in template where uid is session
> variable..
>
> i have set request.session['uid']=str(user.id)
>
> now i want to dothe following in template
> {% if request.session.id %}
> you are logged in
> {% endif %}
> but nothing is showing
>
> here i am loggin user in
> login(request, user)
> request.session['uname']=username
> uu=User.objects.get(username=username)
> request.session['uid']=str(uu.id)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---