provided for backwards compatibility if not feeddict raise http404no feeds are registered slug url partition0 try f feeddictslug except keyerror raise http404slug r isnt registered slug instance f instance feedurl getattrf feedurl none or request path instance titletemplate f titletemplate or feedsstitle html slug instance descriptiontemplate f descriptiontemplate or feedssdescription html slug return instancerequest provided for backwards compatibility
from django.http import Http404
from django.utils.translation import gettext as _


def feed(request, url, feed_dict=None):
    
    if not feed_dict:
        raise Http404(_("No feeds are registered."))

    slug = url.partition("/")[0]
    try:
        f = feed_dict[slug]
    except KeyError:
        raise Http404(_("Slug %r isn’t registered.") % slug)

    instance = f()
    instance.feed_url = getattr(f, "feed_url", None) or request.path
    instance.title_template = f.title_template or ("feeds/%s_title.html" % slug)
    instance.description_template = f.description_template or (
        "feeds/%s_description.html" % slug
    )
    return instance(request)