Changes between Initial Version and Version 1 of Ticket #29852, comment 6


Ignore:
Timestamp:
Oct 16, 2018, 2:54:47 PM (6 years ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #29852, comment 6

    initial v1  
    1919}}}
    2020
    21 In this sense `MinValueValidator(SimpleLazyObject(datetime.now))` is really just a slightly deferred `datetime.now()` as the first time the wrapped function is evaluated the returned value is persisted. In other words `MinValueValidator(SimpleLazyObject(datetime.now))` is really equivalent to `MinValueValidator(datetime.now())` and is the same class of problems the `DateTimeField(default=datetime.now())` check was dealing with.
     21In this sense `MinValueValidator(SimpleLazyObject(datetime.now))` is really just a slightly deferred `datetime.now()` as the first time the wrapped function is evaluated the returned value is persisted. In other words `MinValueValidator(SimpleLazyObject(datetime.now))` is really equivalent to `MinValueValidator(datetime.now())` and is the same class of problems the `DateTimeField(default=datetime.now())` `fields.W161` check is dealing with.
    2222
    2323Now what I think you were trying to do here is provide a validator that makes sure it's not possible to provide a past datetime value and this was not working appropriately as the validator was actually performing a check against the first time the `SimpleLazyObject` wrapped function was resolved. For this purpose you should be using `django.utils.lazy` instead.
Back to Top