Hide Forgot
It wastes resources to get a whole Product object repeatedly each time methods get called, which is only for constructing QuerySet search criteria. Cache every Product object's ID got previously will save much resources. The cache could be a simple dict, maintaining the mapping from id and name to Product's id individually. Like this, { 1: 1, 'Product 1 name': 1, 2: 2, 'Product 2 name': 2, .... } Here, we really don't need to map to a whole Product object, the ID is enough. Meanwhile, with this cache, it's possible to simplify pre_check_product method also.