summaryrefslogtreecommitdiff
path: root/django/utils/functional.py
diff options
context:
space:
mode:
authorMarten Kenbeek <marten.knbk@gmail.com>2015-06-20 14:00:55 +0200
committerTim Graham <timograham@gmail.com>2015-06-23 09:16:17 -0400
commit290ff35e6cc2580861a6fdeaaa3d4aa6d75f9edd (patch)
tree781306423c6d378321f416be5d7f667a2b2010a5 /django/utils/functional.py
parentc45fbd060a3173edd868fc011614f01bc61b78b6 (diff)
Fixed #25000 -- Fixed cast to string for lazy objects.
Implemented __str__() to return the string-representation of the proxied object, not the proxy itself, if the lazy object didn't have a string-like object in its resultclasses.
Diffstat (limited to 'django/utils/functional.py')
-rw-r--r--django/utils/functional.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py
index c0d19093fc..ee0a1953dd 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -128,6 +128,11 @@ def lazy(func, *resultclasses):
else:
return func(*self.__args, **self.__kw)
+ def __str__(self):
+ # object defines __str__(), so __prepare_class__() won't overload
+ # a __str__() method from the proxied class.
+ return str(self.__cast())
+
def __ne__(self, other):
if isinstance(other, Promise):
other = other.__cast()