Common querys as propertys

Exists some severe problem with do heavy tasks like fetch a query in the template?. Your reasoning makes totally sense to me, but i found alternatives that extend my original idea, but including a cache with the cached_property decorator, this is some example.

I think on the surface it could be said that both are ways of optimizing, but in the major of the cases, your approach is the best. However when some form of cache is involved, the propertys cache fits better. My question is whether it is really bad to fetch querys on the template, because if the cached is implemented over redis, this is equal a one TCP requests to the redis server (more cheap that the request to the DB plus the extra processing) but at the end of the bill it can be considered a delayed process.

I have seen that they recommend not to do heavy tasks in the template, but what is heavy?, it is a CPU-time consume process or is a I/O request, this apply when you are using a django version without async (because in the async version totally makes sense not to block the event loop) or in the sync versions this don’t really matter, at the end of the bill is a one to one relation between one thread and one handler request.