Opened 6 years ago

Closed 3 years ago

#14656 closed Bug (fixed)

Atom1Feed should write atom:published element

Reported by: ttencate@… Owned by: Deacalion
Component: contrib.syndication Version: master
Severity: Normal Keywords:
Cc: Deacalion Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Atom1Feed currently produces XML like this:

  <link href="..." rel="alternate"></link>
  <summary type="html">...</summary>

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.


   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:


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.

I suggest also writing the published element, because this is the intended usage of that element. The updated element is mandatory, so it should still be written as well.

However, maybe this needs review by someone who knows more about Atom and the peculiarities of various feed readers.

Attachments (1)

14656.patch (2.2 KB) - added by matt@… 5 years ago.
A Git patch for this bug.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 6 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by jaddison

  • Severity set to Normal
  • Type set to Bug

comment:3 Changed 5 years ago by floledermann

  • Easy pickings unset

Btw. a hacky workaround is monkeypatching the method:

from django.utils.feedgenerator import Atom1Feed, rfc3339_date

# monkey patch buggy Atom implementation in Django
Atom1Feed._add_item_elements = Atom1Feed.add_item_elements

def atom1feed_add_item_elements_patched(self, handler, item, *args, **kwargs):
    if item['pubdate'] is not None:
        handler.addQuickElement(u"published", rfc3339_date(item['pubdate']).decode('utf-8'))
    # include args, kwargs for future compatibility
    self._add_item_elements(handler, item, *args, **kwargs)

Atom1Feed.add_item_elements = atom1feed_add_item_elements_patched

comment:4 Changed 5 years ago by floledermann

It turns out that Google Reader is in fact ignoring publication dates in any format and always displays the date when an entry was first read:

So in fact this bug seems to be rather academic.

Changed 5 years ago by matt@…

A Git patch for this bug.

comment:5 Changed 5 years ago by Deacalion

  • Cc Deacalion added
  • Has patch set
  • UI/UX unset

I came across this last night. I've attached a Git patch, for version 1.3.1.

comment:6 Changed 3 years ago by timo

  • Needs tests set

This needs tests in order to get it committed.

comment:7 Changed 3 years ago by Deacalion

Completely forgot about this one, I'll add tests this evening.

comment:8 Changed 3 years ago by Deacalion

Code, tests and a shred of documentation can be found here:

comment:9 Changed 3 years ago by Deacalion

  • Needs tests unset
  • Version changed from 1.2 to master

comment:10 Changed 3 years ago by Deacalion

  • Owner changed from nobody to Deacalion
  • Status changed from new to assigned

comment:11 Changed 3 years ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In a269ea4fe0a9a7195f1bd8bf5d462f48c226d525:

Fixed #14656 -- Added Atom1Feed published element

Some feed aggregators make use of the published element as well as
the updated element (within the Atom standard --

The standard allows for these two elements to be present in the same
entry. Atom1Feed had implemented the updated element which was
incorrectly taking the date from pubdate.

Note: See TracTickets for help on using tickets.
Back to Top