To speed up the site, in addition to optimizing database queries, you can use caching.
Django allows you to cache:
Class Based View
, and ordinary functions
whole templates or parts of these templates
as well as properties of model objects using
I was interested in the ability to cache individual properties of model objects for heavy computing or heavy database queries.
decorator has such a functional, but the drawback for me was that caching occurred only for the lifetime of the object.
Whereas I need caching for a longer period of time than the existence of an object when requesting a page. And also I needed to cache properties depending on the input arguments. This decorator on the site caches the number of likes and dislikes, as well as information about whether the current user liked a particular content object.
Thus the decorator