A simple Django Application to pull RSS Feeds, pars them and deliver them via JSON

models.py 1.1KB

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.db import models
  4. # Create your models here.
  5. class Feed(models.Model):
  6. name = models.CharField(max_length=100, blank=False, null=False)
  7. url = models.URLField(blank=False, null=False, unique=True)
  8. last_update = models.DateTimeField(null=True)
  9. image = models.ImageField(upload_to='news_logo/', default=None, null=True)
  10. foreground_color = models.CharField(max_length=6, default='#fff')
  11. background_color = models.CharField(max_length=6, default='#000')
  12. def __unicode__(self):
  13. return self.name
  14. class FeedItem(models.Model):
  15. feed = models.ForeignKey('feed', null=False)
  16. headline = models.CharField(max_length=250, blank=False)
  17. body = models.TextField(blank=True, null=True)
  18. published = models.DateTimeField(blank=True, null=True)
  19. uuid = models.CharField(max_length=500, blank=True, null=True)
  20. added = models.DateTimeField(auto_created=True)
  21. class Meta:
  22. unique_together = ('feed', 'headline')
  23. def __unicode__(self):
  24. return "%s: %s" % (self.feed.name, self.headline)