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 request http://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 -~----------~----~----~----~------~----~------~--~---

