I am using django feed framework. This is what I have in my feeds.py:
def item_pubdate(self, item):
return item.posted
This is what I have in my Blog class in models.py:
posted = models.DateField(db_index=True, auto_now_add=True)
And I get this attribute error:
'datetime.date' object has no attribute 'tzinfo'
See https://docs.djangoproject.com/en/dev/ref/contrib/syndication/ for the requirements of
def item_pubdate. This is because most feed formats technically require a full timestamp as the publish date.The function you define
item_pubdatefor a feed must return a pythondatetime.datetimeobject, not adatetime.dateobject. The difference being of course that the object can contain a specific time in addition to the date information.Therefore, you must use
models.DateTimeFieldinstead ofmodels.DateField.—
If you are stuck using the
models.DateField, then you can have your feed class do the conversion:And that should get your date converted to a datetime so that contrib.syndication accepts it.