3👍
It is quite easy:
class CorrectMimeTypeFeed(DefaultFeed):
content_type = 'application/xml; charset=utf-8'
class LatestEntriesFeed(Feed):
feed_type = CorrectMimeTypeFeed
Django rssfeed class’ default type is application/rss+xml; charset=utf-8
Change it, and it will work.
0👍
I Created a html file in template directory and render all feed to that html like below code.
class getTenderfeeds(Feed):
title = "Tender Links"
link = "/rss-tender/"
description = "Tender link feeds"
def __call__(self, request, *args, **kwargs):
try:
obj = self.get_object(request, *args, **kwargs)
except ObjectDoesNotExist:
raise Http404('Feed object does not exist.')
feedgen = self.get_feed(obj, request)
response = HttpResponse(content_type=feedgen.content_type)
if hasattr(self, 'item_pubdate') or hasattr(self, 'item_updateddate'):
response['Last-Modified'] = http_date(
timegm(feedgen.latest_post_date().utctimetuple()))
feedgen.write(response, 'utf-8')
response = re.sub(r'><', '>\n<', str(response))
response = response.replace('Content-Type: application/rss+xml; charset=utf-8','')
return render_to_response('html/feed/rss-tender.html',{ 'response':response,})
def items(self):
return CareerTenderCT.objects.order_by('-cart_created_datetime')[:3]
def item_title(self, item):
return item.cart_title
def item_description(self, item):
return item.cart_desc
def item_link(self, item):
return '/view/12/'+ item.cart_absolute_url
- [Django]-Using Django's test client, make a request using an in-memory file
- [Django]-Cache for everybody except staff members
Source:stackexchange.com