Skip to content

Commit

Permalink
Fix django deprecation warning for django.utils.timezone.utc (#48)
Browse files Browse the repository at this point in the history
The ImportError was always thrown:
No module named 'datetime.timezone'; 'datetime' is not a package
  • Loading branch information
dzonecat committed Nov 24, 2023
1 parent 55a4cb1 commit 4d77733
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ninja_jwt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from ninja_jwt import exceptions

try:
from datetime.timezone import utc
from datetime import timezone
except ImportError:
from django.utils.timezone import utc
from django.utils import timezone


logger = logging.getLogger("django")
Expand Down Expand Up @@ -45,7 +45,7 @@ def import_callable(path_or_callable):

def make_utc(dt):
if settings.USE_TZ and is_naive(dt):
return make_aware(dt, timezone=utc)
return make_aware(dt, timezone=timezone.utc)

return dt

Expand Down

0 comments on commit 4d77733

Please sign in to comment.