AH! If I remember correctly, I also asked about this when I started
using Django. There's a reason you can't call complex functions in the
template: code separation/DRY/etc.
If you want the data, get it in views.py and pass it to the template.
The heavy lifting should be done in the views.py (as functions) or
models.py (as class methods) and then passed into the template using
I was frustrated by this at first, but by the end I was a convert -
makes things much cleaner.
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”