Ticket #7936: syndication-lastmodified.2.diff

File syndication-lastmodified.2.diff, 1.1 KB (added by julianb, 5 years ago)

Patch updated against 1.2.1

  • django/contrib/syndication/views.py

     
    77from django.utils import feedgenerator, tzinfo
    88from django.utils.encoding import force_unicode, iri_to_uri, smart_unicode
    99from django.utils.html import escape
     10from django.utils.http import http_date
     11import time
    1012
    1113def add_domain(domain, url):
    1214    if not (url.startswith('http://')
     
    3335            raise Http404('Feed object does not exist.')
    3436        feedgen = self.get_feed(obj, request)
    3537        response = HttpResponse(mimetype=feedgen.mime_type)
     38        if getattr(self, "item_pubdate", False):
     39            # if item_pubdate is defined by user, set header so
     40            # ConditionalGetMiddleware is able to send 304 NOT MODIFIED
     41            response['Last-Modified'] = http_date(time.mktime(feedgen.latest_post_date().timetuple()))
    3642        feedgen.write(response, 'utf-8')
    3743        return response
    3844
Back to Top