Ticket #18112: feedviews.diff

File feedviews.diff, 1.8 KB (added by slinkp, 3 years ago)
  • django/contrib/syndication/views.py

     
    9090    def get_object(self, request, *args, **kwargs):
    9191        return None
    9292
     93    def get_context_data(self, **kwargs):
     94        """
     95        Returns a dictionary to use as extra context if either
     96        ``self.description_template`` or ``self.item_template`` are used.
     97
     98        Default implementation preserves the old behavior
     99        of using {'obj': item, 'site': current_site} as the context.
     100        """
     101        return {'obj': kwargs.get('item'), 'site': kwargs.get('site')}
     102
    93103    def get_feed(self, obj, request):
    94104        """
    95105        Returns a feedgenerator.DefaultFeed object, fully populated, for
     
    136146                pass
    137147
    138148        for item in self.__get_dynamic_attr('items', obj):
     149            context = self.get_context_data(item=item, site=current_site,
     150                                            obj=obj, request=request)
    139151            if title_tmp is not None:
    140                 title = title_tmp.render(RequestContext(request, {'obj': item, 'site': current_site}))
     152                title = title_tmp.render(RequestContext(request, context))
    141153            else:
    142154                title = self.__get_dynamic_attr('item_title', item)
    143155            if description_tmp is not None:
    144                 description = description_tmp.render(RequestContext(request, {'obj': item, 'site': current_site}))
     156                description = description_tmp.render(RequestContext(request, context))
    145157            else:
    146158                description = self.__get_dynamic_attr('item_description', item)
    147159            link = add_domain(
Back to Top