diff --git a/django/utils/functional.py b/django/utils/functional.py index b78706e073..0bc641cb21 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -163,6 +163,9 @@ def lazy(func, *resultclasses): def __mod__(self, other): return self.__cast() % other + def __mul__(self, other): + return self.__cast() * other + # Add wrappers for all methods from resultclasses which haven't been # wrapped explicitly above. for resultclass in resultclasses: diff --git a/tests/utils_tests/test_functional.py b/tests/utils_tests/test_functional.py index 0fc6ee97da..c8b8fe5a3f 100644 --- a/tests/utils_tests/test_functional.py +++ b/tests/utils_tests/test_functional.py @@ -230,6 +230,7 @@ class FunctionalTests(SimpleTestCase): lazy_5 = lazy(lambda: 5, int) self.assertEqual(4 * lazy_5(), 20) self.assertEqual(lazy_4() * 5, 20) + self.assertEqual(lazy_4() * lazy_5(), 20) def test_lazy_mul_list(self): lazy_4 = lazy(lambda: [4], list)