Reputation: 233
I'm publishing a feed from a Django application.
I subclassed django.contrib.syndication.feeds.Feed, everything works fine, except the date that doesn't get published on the feed.
Here's the method I've created on my Feed class
def item_pubdate(self, item): return item.date
this method never gets called....
Upvotes: 0
Views: 667
Reputation:
According to the Feed Class Reference in the Django documentation, the item_pubdate field is supposed to return a datetime.datetime object. If item.date is just a DateField and not a DateTimeField, that might be causing the problem. If that is the case you could change the method to make a datetime and then return that.
import datetime
def item_pubdate(self, item):
return datetime.datetime.combine(item.date, datetime.time())
Upvotes: 3
Reputation: 44
I've been banging my head against this one for a while. It seems that the django rss system need a "datetime" object instead of just the date (since it wants a time zone, and the date object doesn't have a time, let alone a time zone...)
I might be wrong though, but it's something that I've found via the error logs.
Upvotes: 0
Reputation: 7461
This is how mine is setup, and it is working.
class AllFeed(Feed):
def item_pubdate(self, item):
return item.date
Upvotes: 0