I suggesting to use django-atompub for Atom feed generation.
It has very nice Class abstraction with lots of options, so no any XML hacking, high-level Python code only.
Example:
# Define feed class
class StreamFeed(Feed):
... [snipped]
def item_links(self, item):
return [{'rel': 'enclosure', 'href': item.file.url, 'length': item.file.size, 'type': item.mime.name},
{'rel': 'alternate', 'href': full_url(item.get_absolute_url())}]
I used it in my open source photoblog django app. You can see examples via bitbucket repo.
Complete feed generation code.