8👍
✅
Use timezone.localize instead of datetime.replace
>>> test = datetime.datetime(2016, 9, 28, 10, 10, 10)
>>> test = pytz.timezone('America/Sao_Paulo').localize(test)
datetime.datetime(2016, 9, 28, 10, 10, 10, tzinfo=<DstTzInfo 'America/Sao_Paulo' BRT-1 day, 21:00:00 STD>)
>>> timezone.activate(pytz.timezone('America/Sao_Paulo'))
>>> timezone.localtime(test)
datetime.datetime(2016, 9, 28, 10, 10, 10, tzinfo=<DstTzInfo 'America/Sao_Paulo' BRT-1 day, 21:00:00 STD>)
Reference :
Source:stackexchange.com