[Answer]-Django: 'unicode' object has no attribute 'year'. What format date/time do I need?

1👍

The timesince filter only accepts dates, not date and time combinations. It displays the time difference from the current time (or optionally, a passed in date to compare with).

In your view, parse that string to its date component only. If it you already have it as a datetime object, simply call .date() on it to get the date part.

If you have it as a string:

fmt = "%Y-%m-%dT%H:%M:%S.%f"
date_only = datetime.strptime("2013-06-20T11:20:05.499274", fmt).date()

Leave a comment