[Answered ]-Why is this Django class-based year archive view not working?

1👍

Can you try this:

class LogbookYearArchive(YearArchiveView):
    """Yearly archives of articles"""
    model = Entry
    date_field = 'pub_date'
    year_format='%Y'
    make_object_list=True, 
    template_name = 'hth/archive_year.html'
    allow_future = False
    queryset = Entry.objects.filter(
      is_active=True, kind='A').order_by('-pub_date', 'title')

I added a queryset attribute and removed get_context_data()

1👍

I had the same problem. All ArchiveViews were working except YearArchiveView. Solution was found in make_object_list property. It should be True

That’s a cut from django code

if not self.get_make_object_list():
    # We need this to be a queryset since parent classes introspect it
    # to find information about the model.
    qs = qs.none()
👤Alexey

Leave a comment