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 %}
<p>Welcome, {{ user.username }}. Thanks for logging in.</p>
{% else %}
<p>Welcome, new user. Please log in.</p>
{% 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 %}
> > <p>{{ user.username }} is logged in.</p>
> > {% else %}
> > <p>You are not logged in.</p>
> > {% 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 [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
-~----------~----~----~----~------~----~------~--~---