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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---