I am using Django 1.11
.
My settings.py
has following configured:
TIME_ZONE = 'Asia/Calcutta'
USE_I18N = True
USE_L10N = True
USE_TZ = True
which is IST (Indian Standard Time). My system is set to IST. MySQL
current_time
returns IST, Django's server when running, shows timestamp in IST. Python's datetime.now()
also gives IST.
Now the problem is, my models.py
has following fields:
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
and the database is MySQL. When I insert any record in it, the timestamps are in UTC. I was thinking of adding some middleware, as suggested by this answer, but that doesn't feel to be the recommended way. Why is it taking UTC even when everywhere IST has been configured? Am I missing some config that needs to be set separately for models?
Please note that this question is not similar to what I require. I want to change the overall timezone, so that it is effective in model's too.