In your production environment, i['month']
is already a datetime.datetime
object:
>>> import datetime
>>> example = u'2013-06-01 00:00:00'
>>> example = datetime.datetime.strptime(example, "%Y-%m-%d %H:%M:%S")
>>> example = datetime.datetime.strptime(example, "%Y-%m-%d %H:%M:%S")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: must be string, not datetime.datetime
So to find the difference between your production and development environments, you'll have to trace what produces report
and find out why one environment produces strings, and the other produces datetime.datetime
objects instead.
If you are using datetime operations on your server backend, take into account that some SQL servers support native datetime arithmetic, but SQLite (the database you usually develop against) does not. PostgreSQL will produce datetime
objects, SQLite produces strings.
You'll either want to switch how you handle dates here based on your database settings, or detect if you already have a datetime
object and skip parsing.