Changes between Initial Version and Version 1 of Ticket #29852, comment 6
- Timestamp:
- Oct 16, 2018, 2:54:47 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #29852, comment 6
initial v1 19 19 }}} 20 20 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.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())` `fields.W161` check is dealing with. 22 22 23 23 Now 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.