I'm trying to implement this:
{{{
MinValueValidator(SimpleLazyObject(datetime.date.today))(datetime.date(2018,
9, 19))
}}}
The reason it doesn't work seems to be because `__lt__` and `__gt__` are
not implemented in `LazyObject`.
When i make the following change:
{{{
class Simple(SimpleLazyObject):
__lt__ = new_method_proxy(operator.lt)
__gt__ = new_method_proxy(operator.gt)
MinValueValidator(Simple(datetime.date.today))(datetime.date(2018, 9, 17))
ValidationError: [u'Ensure this value is greater than or equal to
2018-09-19.']
}}}
I get my expected result.
This doesn't seem like an unreasonable ask.
--
Ticket URL: <https://code.djangoproject.com/ticket/29772>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Uncategorized => New feature
* component: Uncategorized => Core (Other)
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/29772#comment:1>
Comment (by Javier Buzzi):
@Simon Charette Can this go into 2.0 or.. 1.x? If not i'll wait i suppose.
This diff can be back ported without difficulty. Ps. i have PR:
https://github.com/django/django/pull/10419 not sure where to put it.
--
Ticket URL: <https://code.djangoproject.com/ticket/29772#comment:2>
* version: 2.1 => master
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/29772#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"a0d63b02c34e6d18d7219cce4d828f71432265e9" a0d63b0]:
{{{
#!CommitTicketReference repository=""
revision="a0d63b02c34e6d18d7219cce4d828f71432265e9"
Fixed #29772 -- Made LazyObject proxy __lt__() and __gt__().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29772#comment:4>