I am having alot of trouble getting Django to render a datetime field in my local timzeone.
Settings.py has:
TIME_ZONE = 'UTC'
USE_TZ = True
USE_L10N = True
In my model I have:
class ExportRecord(models.Model):
[...]
created = models.DateTimeField(auto_now_add=True)
def save(self, *args, **kwargs):
[...]
self.created = timezone.now()
Created gets stored as a UTC time object in MySQL.
If I have "2016-11-08 01:25:15" in the database after the created field is populated, when I render my template I expect it to be translated into the local time of the client (I am in eastern time, so I expected it to be "2016-11-07 20:25:15".
However, no matter what tags I use (for example {{ date_obg | localtime }}), the date will not be rendered as my local time.
I installed tzlocal and when I run get_localzone() in my view it shows 'UTC' as the output.
Furthermore, if I try this (converting my created field from UTC to my local timezone variable):
lctz = get_localzone()
self.created.replace(tzinfo=pytz.utc).astimezone('lctz')
>>>>2016-11-08 01:25:15
The created date stays the same as it is in the DB (which is in UTC).
Is this because the local timezone of my Google App Engine instance is in UTC? How do I get my applications templates to render in my user/client timezones?