from django.db import models
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.template.loader import render_to_string

import feedparser


class RSSContent(models.Model):
    link = models.URLField(_('link'))
    rendered_content = models.TextField(_('Pre-rendered content'), blank=True, editable=False)

    class Meta:
        abstract = True

    def render(self, **kwargs):
        return mark_safe(self.rendered_content)
        #u'<div class="rsscontent"> RSS: <a href="'+self.link+'">'+self.link+'</a></div')

    def cache_content(self):
        print u"Getting RSS feed at %s" % (self.link,)
        feed = feedparser.parse(self.link)

        print u"Pre-rendering content"
        self.rendered_content = render_to_string('rsscontent.html', {
            'feed': feed})

        self.save()


@@ -1,20 +1,51 @@
+from datetime import datetime%0A%0A
 from django.db impor
@@ -53,16 +53,16 @@
  models%0A
-
 from dja
@@ -392,16 +392,98 @@
 e=False)
+%0A    last_updated = models.DateTimeField(_('Last updated'), blank=True, null=True)
 %0A%0A    cl
@@ -925,16 +925,16 @@
 tml', %7B%0A
-
         
@@ -951,16 +951,59 @@
 : feed%7D)
+%0A        self.last_updated = datetime.now()
 %0A%0A      

Add last_updated field to RSSContent