I am new to Django (since version 1.3). When creating the application from day one, I went with new universal class-based views, using a combination of built-in classes and subclassing them where I needed to be added to the context.
Now my problem is that I need to go back to my views and make them available only for login. All the documentation I found shows how to do this with old functional universal views, but not with a class.
Here is an example class:
class ListDetailView(DetailView): context_object_name = "list" def get_queryset(self): list = get_object_or_404(List, id__iexact=self.kwargs['pk']) return List.objects.all() def get_context_data(self, **kwargs): context = super(ListDetailView, self).get_context_data(**kwargs) context['subscriber_list'] = Subscriber.objects.filter(lists=self.kwargs['pk']) return context
How to add authentication to new django based classes?
pwalsh
source share