Why does the Django Atom1Feed use atom:updated instead of atom:published?
I made an Atom feed in Django using a class that looks something like this:
class AtomFeed(Feed):
开发者_如何学编程 feed_type = feedgenerator.Atom1Feed
# ...
def item_pubdate(self, post):
return datetime.datetime(post.date.year, post.date.month, post.date.day)
The resulting XML for an item:
<entry>
<title>..</title>
<link href="..." rel="alternate"></link>
<updated>2010-10-18T00:00:00+02:00</updated>
<author><name>...</name></author>
<id>...</id>
<summary type="html">...</summary>
</entry>
The thing to note here is that the date goes in the atom:updated
element, not the atom:published
element.
The RFC clearly suggests to me that this is not the intended usage:
The "atom:updated" element is a Date construct indicating the most recent instant in time when an entry or feed was modified in a way the publisher considers significant. Therefore, not all modifications necessarily result in a changed atom:updated value.
Whereas:
The "atom:published" element is a Date construct indicating an instant in time associated with an event early in the life cycle of the entry.
This is more than just a theoretical problem. Google Reader, for example, does not seem to use the updated
element, and uses the date that it first saw the item appear. As a result, it does not order the items properly upon first import of the feed.
The code in Django responsible for this:
django/utils/feedgenerator.py:331
if item['pubdate'] is not None:
handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('utf-8'))
There appears to be no mention of the published
element.
Is this a bug in Django? Am I misunderstanding the Atom RFC? Am I missing something else?
You are not missing anything. The Atom RFC is correct, and this is a known bug in Django; see this Django bug.
It looks like a relatively simple fix, so feel free to get in there and patch it! ^_^
精彩评论