from django.utils.feedgenerator import SyndicationFeed from django.core.serializers.json import DjangoJSONEncoder import json class JSONFeed(SyndicationFeed): mime_type = "application/json" def write(self, outfile, encoding): data={} data.update(self.feed) data['items'] = self.items json.dump(data, outfile, cls=DjangoJSONEncoder) # outfile is a HttpResponse if isinstance(outfile, HttpResponse): outfile['Access-Control-Allow-Origin'] = '*' class MyJSONFeed(MyPlainFeed): feed_type = JSONFeed