If you call a model method with heavy calculations or database queries multiple times in the request-response cycle, the performance of the view might be very slow. In this recipe, you will learn about a pattern that you can use to cache the return value of a method for later repetitive use. Note that we are not using the Django cache framework here, only what Python provides us by default.
Caching the method return value
Getting ready
Choose an app with a model that has a time-consuming method that will be used repetitively in the same request-response cycle.