mirror of
https://github.com/django/django.git
synced 2025-09-18 00:10:22 +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:
parent
c45fbd060a
commit
290ff35e6c
2 changed files with 29 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue