Skip to content

Commit 80322cf

Browse files
🐛 fix(handlers): use localtime() to respect TIME_ZONE setting
Replaced timezone.now() with timezone.localtime() in EmailHandler to ensure the correct local time is used for log emails, matching the configured TIME_ZONE setting in Django. Closes #88
1 parent a8093ac commit 80322cf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

django_logging/handlers/email_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django.conf import settings
55
from django.http import HttpRequest
66
from django.template import engines
7-
from django.utils.timezone import now
7+
from django.utils.timezone import localtime
88

99
from django_logging.middleware import RequestLogMiddleware
1010
from django_logging.utils.get_conf import use_email_notifier_template
@@ -46,7 +46,7 @@ def render_template(
4646
)
4747

4848
# Get current time
49-
current_time = now()
49+
current_time = localtime()
5050

5151
# Format date and time separately
5252
formatted_date = current_time.strftime("%d %B %Y").replace(

0 commit comments

Comments
 (0)