I actually don’t think
views.py is the right place for any of the custom logic presented in the article.
If I had to yank something out I would pull the report to a separate file. The file would contain a function that accept a queryset (the filtered queryset generated by the admin), a period (generate from get_next_in_date_hierarchy) and return a proper type with results and summary.
IMO the appropriate place for such logic is either in
models.py or at a designated file such as