tags:

views:

206

answers:

3

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....

A: 

This is how mine is setup, and it is working.

class AllFeed(Feed):
    def item_pubdate(self, item):
        return item.date
phillc
teh code seems identical, may be there is a bug on the django trunk...
lorenzov
im usingthe 1.0.2 tag.
phillc
That code works fine for me too.
Dominic Rodger
A: 

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.

Jonathan Lin
A: 

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())