以下は、Django Con EU トーク ビデオを見た後、ファースト クラス ベースのビューで作成したものです。
それは機能し、それが何をするかを理解しています。クラス ベース ビューとジェネリック クラス ベース ビューの違いがわかりません - どちらを作成したのですか?
class GroupListView(ListView):
"""
List all Groups.
"""
context_object_name = 'groups'
template_name = 'contacts/home.html'
def get_context_data(self, **kwargs):
"""
Get the context for this view.
"""
# Call the base implementation first to get a context.
context = super(GroupListView, self).get_context_data(**kwargs)
# Add more contexts.
context['tasks'] = Upload.objects.filter(uploaded_by=self.request.user).order_by('-date_uploaded')[:5]
context['unsorted'] = Contact.objects.unsorted_contacts(user=self.request.user).count()
return context
def get_queryset(self):
"""
Get the list of items for this view. This must be an iterable, and may
be a queryset (in which qs-specific behavior will be enabled).
"""
queryset = Group.objects.for_user(self.request.user)
return queryset