Replaying to myself To find the generic view def look at (at least in Debian): /usr/share/python-support/python-django/django/views/generic/list_detail.py In this file there is the definition of object_list and object_detail
So the urls are: (r'^libri/$', 'mysite.biblioteca.views.lista_libri', info_dict, "Libri"), (r'^libri/(?P<object_id>\d+)/$', 'mysite.biblioteca.views.dettaglio_libri', info_dict, "Libro"), And the views are: from django.views.generic.list_detail import object_detail from django.views.generic.list_detail import object_list @login_required def lista_libri(*args, **kwargs): return object_list(*args, **kwargs) @login_required def dettaglio_libri(*args, **kwargs): return object_detail(*args, **kwargs) Regards Mirto Mirto Silvio Busico ha scritto: > Hi all, > I have a dumb question, but any help will be greately appreciated. > > I'm trying to create a django site with most (but not all) pages are > accessible only for authenticated users. > > I'm using the "@login_required" decorator; but I'm not able to impose > this on generic views. > > Chapter 12 of Django book says: > ___________________________________________________________________________________________________________________ > > Limiting Access to Generic Views > > One of the most frequently asked questions on the Django users list > deals with limiting access to a generic view. > To pull this off, you’ll need to write a thin wrapper around the view > and point your URLconf to your wrapper instead of the generic view itself: > > from dango.contrib.auth.decorators import login_required > from django.views.generic.date_based import object_detail > > @login_required > def limited_object_detail(*args, **kwargs): > return object_detail(*args, **kwargs) > > You can, of course, replace login_required with any of the other > limiting decorators. > __________________________________________________________________________________________________________________ > > > My urls are: > __________________________________________________________________________________________________________________ > > from django.conf.urls.defaults import * > from mysite.biblioteca.models import * > > info_dict = { > 'queryset': Libri.objects.all(), > } > > urlpatterns = patterns('', > (r'^cerca/$', 'mysite.biblioteca.views.cerca'), > (r'^carica/$', 'mysite.biblioteca.views.carica'), > (r'^$', 'mysite.biblioteca.views.indice'), > (r'^libri/$', 'django.views.generic.list_detail.object_list', info_dict, > "Libri"), > (r'^libri/(?P<object_id>\d+)/$', > 'django.views.generic.list_detail.object_detail', info_dict, "Libro"), > ) > __________________________________________________________________________________________________________________ > > So what I have to write in the view? > Something like: > > URL: (r'^libri/$', 'mysite.biblioteca.views.xxx', info_dict, "Libri") > VIEW: > > @login_required > def xxx(*args, **kwargs): > return django.views.generic.list_detail.object_list(*args, **kwargs) > > > Really confused. > Any hint? > > Thanks > Mirto > > -- _________________________________________________________________________ Busico Mirto Silvio Consulente ICT cell. 333 4562651 email [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 -~----------~----~----~----~------~----~------~--~---