I'm using Python 3.7 and none of the solutions from this post -- Python strptime() and timezones? applied to me. I had this for generating a datetime from text ...
datetime.strptime(created_on_txt, '%Y-%m-%dT%H:%M:%S%z')
This later results in the warning ...
DateTimeField Article.created_on received a naive datetime (2019-12-09 00:08:17.670597) while time zone support is active.
So I added a timezone like so ...
datetime(pytz.timezone(settings.TIME_ZONE)).strptime(created_on_txt, '%Y-%m-%dT%H:%M:%S%z')
But this results in the error ...
TypeError: an integer is required
What's the right way to get the timezone into the datetime?