Skip to content

Commit

Permalink
datetime import changed to fix the now obsolete .utcnow() call
Browse files Browse the repository at this point in the history
  • Loading branch information
theriverman committed Sep 2, 2024
1 parent 2e6e7ac commit 8d6671d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DjangoExampleApplication/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import uuid
import datetime
from datetime import timezone
from django.db import models
from django.db.models.fields.files import FieldFile
from django.contrib.contenttypes.models import ContentType
Expand All @@ -9,7 +8,8 @@


def get_iso_date() -> str:
now = datetime.datetime.utcnow().replace(tzinfo=timezone.utc)
"""Get current date in ISO8601 format [year-month-day] as string"""
now = datetime.datetime.now(datetime.UTC)
return f"{now.year}-{now.month}-{now.day}"


Expand Down
6 changes: 3 additions & 3 deletions DjangoExampleApplication/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def tearDown(self):
def test_url_generation_works(self):
"""Accessing the value of obj.image.url"""
val = URLValidator()
val(self.obj.image.url) # 1st make sure it's an URL
val(self.obj.image.url) # 1st make sure it's a URL
self.assertTrue('audience-868074_1920' in self.obj.image.url) # 2nd make sure our filename matches

def test_read_image_size(self):
Expand All @@ -52,7 +52,7 @@ def setUp(self):
def test_url_generation_works(self):
"""Accessing the value of obj.file.url"""
val = URLValidator()
val(self.obj.file.url) # 1st make sure it's an URL
val(self.obj.file.url) # 1st make sure it's a URL
self.assertTrue('public_audience-868074_1920' in self.obj.file.url) # 2nd make sure our filename matches

def test_read_file_size(self):
Expand All @@ -78,7 +78,7 @@ def setUp(self):
def test_url_generation_works(self):
"""Accessing the value of obj.file.url"""
val = URLValidator()
val(self.obj.file.url) # 1st make sure it's an URL
val(self.obj.file.url) # 1st make sure it's a URL
self.assertTrue('private_audience-868074_1920' in self.obj.file.url) # 2nd make sure our filename matches

def test_read_file_size(self):
Expand Down

0 comments on commit 8d6671d

Please sign in to comment.