Opened 6 years ago
Closed 6 years ago
#29772 closed New feature (fixed)
SimpleLazyObject doesn't implement __gt__ / __lt__
Reported by: | Javier Buzzi | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Similar ticket: https://code.djangoproject.com/ticket/26287
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.
Change History (4)
comment:1 by , 6 years ago
Component: | Uncategorized → Core (Other) |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → New feature |
comment:2 by , 6 years ago
comment:3 by , 6 years ago
Triage Stage: | Accepted → Ready for checkin |
---|---|
Version: | 2.1 → master |
Note:
See TracTickets
for help on using tickets.
@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.