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 report.py.

Full Stack Developer, Team Leader, Independent. More from me at https://hakibenita.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store