PYTHON   38

views.py

Guest on 3rd June 2021 06:00:52 AM

  1. from __future__ import unicode_literals
  2.  
  3. from django.http import Http404
  4. from django.utils.translation import ugettext as _
  5.  
  6.  
  7. def feed(request, url, feed_dict=None):
  8.     """Provided for backwards compatibility."""
  9.     if not feed_dict:
  10.         raise Http404(_("No feeds are registered."))
  11.  
  12.     slug = url.partition('/')[0]
  13.     try:
  14.         f = feed_dict[slug]
  15.     except KeyError:
  16.         raise Http404(_("Slug %r isn't registered.") % slug)
  17.  
  18.     instance = f()
  19.     instance.feed_url = getattr(f, 'feed_url', None) or request.path
  20.     instance.title_template = f.title_template or ('feeds/%s_title.html' % slug)
  21.     instance.description_template = f.description_template or ('feeds/%s_description.html' % slug)
  22.     return instance(request)

Raw Paste


Login or Register to edit or fork this paste. It's free.