On Sat, Mar 7, 2009 at 1:59 PM, jmat <joshmat...@gmail.com> wrote:

>
> I'm trying to figure out a way to use the django.contrib.auth tools at
> the root of the site for login but I'm running into one issue (I know
> I can write my own view....but not trying not to do that here).
>
> So I have this in my urls.py
>
> (r'^$',  login, {'template_name':'login_base.html'}),
>
> so when a user goes to mysite.com/
> they get the login page at login_base.html and login.
>
> Now they are logged in and they get redirected after login to:
>
> mysite.com/userspage/
>
> Lets say they now navigate to mysite.com/   again ...
>
> they are still logged in but in this case they will go back to
> login_base.html.
>
> Is there a way to redirect them back to mysite.com/userpage/ from
> mysite.com/  if they are already logged in (that is without writing my
> own view to handle the auth,login stuff ?
> >
>
Write your own view, but basically have it do:

def my_view(request):
    if request.user.is_authenticated():
        do_my_stuff()
    else:
       return login(request)

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to