Simply have an 'if logged in:' clause at the beginning of your login
view definition that redirects to the /loggedin/ view if it matches.

Of course this implies that you know some variable that will always
match once someone is logged in.

Most likely, django sets this already. If you cannot find one, you
just set one yourself.

I am new to django, only started learning it last week, so the
solution may look a bit dirty in the eyes of seasoned django
developers, but i am sure it will work.

Have a look at the forms chapter, and read about the
HttpResponseRedirect to see how to go about doing the redirect.

HTH

Jon.

On May 19, 10:43 am, Rok <[email protected]> wrote:
> But what if "user" specify login URL in the browser? He gets login
> form regardless if he is logged in or not.
>
> For example I have ( r'^login/$', login ) in urls.py and if I 
> requesthttp://localhost:8000/login/I get login form even though I am already
> logged in; but I want to show some message that he/she is already
> logged in.
>
> On 19 maj, 00:41, jon michaels <[email protected]> wrote:
>
> > From the documentation it seems that it is not only possible, but
> > required too..
>
> > login_required() does the following:
>
> >     * If the user isn't logged in, redirect to settings.LOGIN_URL
> > (/accounts/login/ by default), passing the current absolute URL in the
> > query string as next or the value of redirect_field_name. For example:
> > /accounts/login/?next=/polls/3/.
> >     * If the user is logged in, execute the view normally. The view
> > code is free to assume the user is logged in.
> > [...]
> > It's your responsibility to provide the login form in a template
> > called registration/login.html by default. This template gets passed
> > four template context variables:[...]
>
> > Source:http://docs.djangoproject.com/en/dev/topics/auth/
>
> > If this doesn't answer your question, please be more specific about
> > the context.
>
> > On Tue, May 19u, 2009 at 1:44 AM, Rok <[email protected]> wrote:
>
> > > Hello.
>
> > > Is it possible to use user object in login.html when @login_required
> > > is used? I want to display login fields only when user is ianonymous.
>
> > > Thank you.
>
> > > Kind regards,
>
> > > Rok
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to