Re: setting up login required pages massly

2007-07-19 Thread Nathan Ostgard

You can define a custom decorator instead, specifying a custom
login_url:

from django.contrib.auth.decorators import user_passes_test
my_login_decorator = user_passes_test(lambda u: u.is_authenticated(),
login_url='/my/login/url')

Then you can use:

@my_login_decorator
def someview(request):
  ...

On Jul 19, 8:39 pm, james_027 <[EMAIL PROTECTED]> wrote:
> hi,
>
> is there a stupidly fast way to make select but many pages to required
> login first? I am using 0.96 @login_required is cool, but 0.96 doesn't
> support LOGIN_URL in the settings.py yet.
>
> currently i am using something like this
>
> if not request.user.is_authenticated():
> return render_to_response('login.htm', {'from':request.path})
>
> for each view's function.
>
> thanks
> james


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



setting up login required pages massly

2007-07-19 Thread james_027

hi,

is there a stupidly fast way to make select but many pages to required
login first? I am using 0.96 @login_required is cool, but 0.96 doesn't
support LOGIN_URL in the settings.py yet.

currently i am using something like this

if not request.user.is_authenticated():
return render_to_response('login.htm', {'from':request.path})

for each view's function.

thanks
james


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