You need to add parenthesis to group the datetime
arithmetic together:
{"contents": "%s" % (datetime.date.today() + datetime.timedelta(days=1))}
because the +
operator has a lower precedence than the %
operator:
>>> "%s" % datetime.date.today() + datetime.timedelta(days=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'datetime.timedelta' objects
>>> "%s" % (datetime.date.today() + datetime.timedelta(days=1))
'2013-11-14'
In the first form, Python evaluated "%s" % datetime.date.today()
first and then you end up adding a string and a timedelta()
object.
You could just use str()
here:
{"contents": str(datetime.date.today() + datetime.timedelta(days=1))}