mongoengine
mongoengine copied to clipboard
datetime.utcnow() deprecation in Python 3.12
datetime.utcnow() was deprecated in Python 3.12, although it's referenced in quite a few places in MongoEngine's docs and test code, e.g.:
Note: To default the field to the current datetime, use: DateTimeField(default=datetime.utcnow)
It seems like it would make sense to do one of the following:
- Update docs to e.g.
DateTimeField(default=lambda: datetime.now(timezone.utc)) - Create a timezone-aware helper called something like
aware_utcnow, with behavior compatible across Python versions
Hi @neilsh, I just made a PR for it #2900