Re: authentication on generic views

2007-10-26 Thread Marty Alchin

On 10/26/07, Hugh Bien <[EMAIL PROTECTED]> wrote:
> I haven't really used generic views that often, but I know you could always
> extend them by creating your own views.
>
> Inside your views.py:
>
>
> from django.views.generic.list_detail import object_list
>
> @login_required
> def my_list(*args, **kwargs):
> return object_list(*args, **kwargs)

Or even just:

from django.views.generic.list_detail import object_list
from django.contrib.auth.decorators import login_required

my_list = login_required(object_list)

And now my_list is a login-protected version of object_list. This is
also more compatible with older versions of Python, in case the app is
ever distributed.

Also note that this can be done either in views.py, or directly in
urls.py. It's your call.

-Gul

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



Re: authentication on generic views

2007-10-26 Thread Hugh Bien
I haven't really used generic views that often, but I know you could always
extend them by creating your own views.
Inside your views.py:

from django.views.generic.list_detail import object_list

@login_required
def my_list(*args, **kwargs):
return object_list(*args, **kwargs)

- Hugh

On 10/25/07, Mike Maravillo <[EMAIL PROTECTED]> wrote:
>
>  Hi,
>
> I'm using the django.views.generic.list_detail.object_list generic view
> because of the handy pagination.  However, I need to have the user accessing
> the page to be authenticated first.  Is there any other way than doing the
> check on the template?  Thanks very much.
>
> Mike
> >
>

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



authentication on generic views

2007-10-25 Thread Mike Maravillo
Hi,

I'm using the django.views.generic.list_detail.object_list generic view
because of the handy pagination.  However, I need to have the user
accessing the page to be authenticated first.  Is there any other way
than doing the check on the template?  Thanks very much.

Mike

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