0

I am using the django-auditlog library to store audit logs concerning some of my models.

I noticed that despite the fact that I have defined the time zone in settings.py all the models containing fields of type DateTimeField are stored in UTC time in my admin panel in Log entries section.

Here is my settings.py part concerning time and time zone configurations :

USE_L10N = True
TIME_ZONE = 'Europe/Athens'
USE_TZ = True

What to do in order the log audit records to be in timezone defined by me and not in UTC?

gtopal
  • 544
  • 1
  • 9
  • 35

1 Answers1

0

I finally found the solution I was searching for.

In settings.py I had to declare the below:

TIME_ZONE = 'Europe/Athens'
USE_L10N = True
USE_TZ = False
class TimezoneMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response
    def __call__(self, request):
        timezone.activate(pytz.timezone('Europe/Athens'))
        return self.get_response(request)
gtopal
  • 544
  • 1
  • 9
  • 35