[Answered ]-Redirect Django feed to FeedBurner

2πŸ‘

βœ…

The problem here is that you removed the django.contrib.syndication.views.feed reference from your urls.py.

Instead of using reverse to redirect to a different URL, try just returning the feed from your existing view:

from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.syndication.views import feed

def redirect(request, **kwargs):
    if request.META['HTTP_USER_AGENT'].startswith('FeedBurner'):
        return feed(request, **kwargs)
    else:
        return HttpResponseRedirect('http://feeds2.feedburner.com/MyFeed')
πŸ‘€Daniel Naab

0πŸ‘

Well, i guess it helps someone, who wonders what is the correct way of doing it in django 1.3+

from django.http import HttpResponseRedirect
from feeds import MyFeed #your feed class, check https://docs.djangoproject.com/en/1.3/ref/contrib/syndication/

def burnedFeed(request, **kwargs):
    if request.META['HTTP_USER_AGENT'].startswith('FeedBurner'):
        feed = MyFeed()
        return feed(request)
    else:
        return HttpResponseRedirect('http://feeds2.feedburner.com/MyFeedName')
πŸ‘€DataGreed

Leave a comment