mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
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.
This commit is contained in:
committed by
Tim Graham
parent
c45fbd060a
commit
290ff35e6c
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user