Home > Enterprise >  Why do i keep getting UTC time zone even when Django settings is configured differently
Why do i keep getting UTC time zone even when Django settings is configured differently

Time:07-24

I'm not sure why the datetime response is always one hour behind (UTC)

Django settings configuration

LANGUAGE_CODE = "en-us"
TIME_ZONE = "Africa/Lagos"
USE_I18N = True
USE_L10N = True
USE_TZ = True
DATE_FORMAT = "F j, Y"
SITE_ID = 1
from django.utils import timezone
timezone.now()

response:
datetime.datetime(2022, 7, 23, 13, 58, 6, 739601, tzinfo=<UTC>)

You can see that the time zone info is UTC

CodePudding user response:

Try: 1.download latest pytz file (pytz-2019.3.tar.gz) from https://pypi.org/simple/pytz/

2.copy and extract it to site_packages directory on your project

3.in cmd go to the exracted folder and run "python setup.py install"

4.TIME_ZONE = 'Etc/GMT 3' or country name

CodePudding user response:

It needs to be done like this:

LANGUAGE_CODE = "en-us"
TIME_ZONE = "Africa/Lagos"
USE_I18N = True
USE_L10N = False
USE_TZ = False
  • Related