[Django]-Django class-based views YearArchiveView


You’ve already solved the issue, but to answer your question about why that option exists, the documentation says:

A yearly archive page showing all available months in a given year.

… the template’s context will be:

  • date_list: A DateQuerySet object containing all months that have objects available according to queryset, represented as datetime.datetime objects, in ascending order.

Class-based views are hard, and it’s worth reading the documentation very carefully, diving into the source (mostly django.views.generic) and getting familiar with debugging techniques to step through the slightly tangled pile of inheritance going on with most views.


It was a newbie mistake. I was not specifying make_object_list in the class. You can see how it’s fixed at this commit.

From the documentation:


A boolean specifying whether to retrieve the full list of objects for this year and pass those to the template. If True, the list of objects will be made available to the context. By default, this is False.

So I’m not sure why that option exists, but it does. It doesn’t make much sense to me to return nothing by default (maybe a pagination thing?)


Yeah. I agree with you. I currently have my own implementation of this class-based generic view working, but I’m curious whether or not it’s “politically correct.” Anyway, it’s very board on how you can use this generic view, and I figured that this (make_object_list) attribute is an available option for coders to tinker with.

Leave a comment