Wiadomość napisana w dniu 2008-11-17, o godz. 10:02, przez TH:

> I wanted to redirect a logged in user if he access certain page. For
> example i do not want the user to access registration page if he is
> logged in.
>
> A simple way to do this is:
>
> def register(request):
>    if request.user.is_authenticated():
>        return HttpResponseRedirect('/
> some_nice_page_for_logged_in_user')
>    ...
>
> The problem is i have lot of pages that only anonymous user can
> access. So i wanted to write a decorator so that i can do something
> like that
>
>
> @anonymous_only
> def register(request):


Take a look at the content of django.contrib.auth.decorators module  
(the _CheckLogin class, a call in user_passes_test
and login_required).

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R&D, Redefine
[EMAIL PROTECTED]


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

Reply via email to