I am pretty new to Django (starting with 1.3). In building an app, I went with the new class-based generic views from day one, using a combination of the built in classes and subclassing them where I needed to add to the context.
Now my problem is, I need to go back to my views, and have them accessible only to logged in users. ALL the documentation I have found shows how to do this with the old functional generic views, but not with class-based.
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 do I add authentication to django's new class-based views?