From c9e459d50829afafba47655443d04220430b1f45 Mon Sep 17 00:00:00 2001 From: Rust Saiargaliev Date: Fri, 8 Dec 2023 15:49:15 +0100 Subject: [PATCH] Fix Python 3.12 deprecation warning in `datetime` `datetime.datetime.utcnow()` is deprecated: https://docs.python.org/3/whatsnew/3.12.html#deprecated --- s3file/storages.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/s3file/storages.py b/s3file/storages.py index 394cdb6..a29cd68 100644 --- a/s3file/storages.py +++ b/s3file/storages.py @@ -21,7 +21,9 @@ class client: def generate_presigned_post(bucket_name, key, **policy): policy = json.dumps(policy).encode() policy_b64 = base64.b64encode(policy).decode() - date = datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%SZ") + date = datetime.datetime.now(tz=datetime.timezone.utc).strftime( + "%Y%m%dT%H%M%SZ" + ) aws_id = getattr( settings, "AWS_ACCESS_KEY_ID",