neolaser
neolaser

Reputation: 6907

Django RSS add attribute into item

Just a quick question that I have been having trouble with all day. Hopefully my google skills just havent failed me ;)

I want to add an extra field to the <item>, something like:

<item>
    <title></title>
    <myfield></myfield>
</item>

Upvotes: 2

Views: 1047

Answers (1)

neolaser
neolaser

Reputation: 6907

Although I dont like answering my own questions, I figured out how and its rather simple...once its demonstrated. Credit does not go to me, but I found this link

from django.utils.feedgenerator import Rss201rev2Feed
class CustomFeedGenerator(Rss201rev2Feed):
    def add_item_elements(self, handler, item):
        super(CustomFeedGenerator, self).add_item_elements(handler, item)
        handler.addQuickElement(u"featured", item['featured'])

then add the following within your feed class definition

def item_extra_kwargs(self, obj):
    return { 'featured': val}

Of course, featured was the field I wanted to add... Thanks to the people at the link I posted above!

Upvotes: 7

Related Questions