Re: Displaying user names on all pages

2008-04-19 Thread chiefmoamba

Hi there,

Thanks for this - it worked  :-)

For any who may read this and need a little extra help, the html page
contained:

{% if user.is_authenticated %}
Welcome, {{ user.username }}. Thanks for logging in.
{% else %}
Welcome, new user. Please log in.
{% endif %}

And views.py also needed to have

from django.template import RequestContext

...in it

Thanks again for your help.

Ed

On Apr 19, 7:43 pm, Raisins <[EMAIL PROTECTED]> wrote:
> Add context_instance=RequestContext(request) to your
> render_to_response for your views
>
> render_to_response('mainpage.html', {'stuff' : stuf },
> context_instance=RequestContext(request))
>
> On Apr 19, 1:36 pm, chiefmoamba <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I am hoping this will be a very simple question for many of you.
>
> > I have built simple Django login function. When I log in, my log in
> > page will say "Welcome, username" etc. It works beautifully.
>
> > However, on subsequent pages, eg /nextpage/ even though I have the
> > same code in the page, the username doesn't display:
>
> > {% if request.user.is_authenticated %}
> > {{ user.username }} is logged in.
> > {% else %}
> > You are not logged in.
> > {% endif %}
>
> > I don't understand why it works on the login page only.
>
> > It may be worth mentioning that I have a login_required decorator on
> > the page so I don't really need the if/else above, I am aware of that
> > but I am being desperate!
>
> > Any thoughts?
>
> > Thanks,
>
> > Ed
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Displaying user names on all pages

2008-04-19 Thread Raisins

Add context_instance=RequestContext(request) to your
render_to_response for your views

render_to_response('mainpage.html', {'stuff' : stuf },
context_instance=RequestContext(request))

On Apr 19, 1:36 pm, chiefmoamba <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am hoping this will be a very simple question for many of you.
>
> I have built simple Django login function. When I log in, my log in
> page will say "Welcome, username" etc. It works beautifully.
>
> However, on subsequent pages, eg /nextpage/ even though I have the
> same code in the page, the username doesn't display:
>
> {% if request.user.is_authenticated %}
> {{ user.username }} is logged in.
> {% else %}
> You are not logged in.
> {% endif %}
>
> I don't understand why it works on the login page only.
>
> It may be worth mentioning that I have a login_required decorator on
> the page so I don't really need the if/else above, I am aware of that
> but I am being desperate!
>
> Any thoughts?
>
> Thanks,
>
> Ed

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Displaying user names on all pages

2008-04-19 Thread chiefmoamba

Hello,

I am hoping this will be a very simple question for many of you.

I have built simple Django login function. When I log in, my log in
page will say "Welcome, username" etc. It works beautifully.

However, on subsequent pages, eg /nextpage/ even though I have the
same code in the page, the username doesn't display:

{% if request.user.is_authenticated %}
{{ user.username }} is logged in.
{% else %}
You are not logged in.
{% endif %}

I don't understand why it works on the login page only.

It may be worth mentioning that I have a login_required decorator on
the page so I don't really need the if/else above, I am aware of that
but I am being desperate!

Any thoughts?

Thanks,

Ed
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---