see ya
sebey
If your models include Feed and FeedItem (FeedItem having a foreignkey
to a Feed), then feed parser will do something like this:
f = feedparser.parse('http://somefeed.url')
feed = Feed.objects.get(link=f.feed.link) # f.feed provides
information corresponding to one Feed instance
for item in f['entries']: # entries are all the items under a
particular feed
it, created = FeedItem.objects.get_or_create(title=item.title,
link=item.link, desc=item.description, date=item.date_parsed,
id=item.id, feed=feed)
Repeat the above for every url in your list of feed urls. Note: this
code goes in your standalone script running on a cron job, NOT in your
views or whatever other normal part of your django code base. That
will put RSS feed items into your database, your views.py pulls them
out again as per normal django methods:
feed = Feed.objects.get(link=somelinkvalue)
items = feed.feeditem_set.all()
return render_to_response(template, {'items':items})
That's how it ought it work, in my opinion. Note that it's late here,
and I've been drinking, so there may be some inaccuracies in the
above. I concur with the general consensus, that you need to start
with some simple CGI scripts and python basics, and move up from
there. That said, good luck!
E
see ya
sebey
from ubermicro.shows.models import Feed
feeds = Feed.objects.all()
for feed in feeds:
f = feedparser.parse(feed.link)
for item in f['entries']:
# continue as below
So you'll add Feeds in the admin, but your standalone script will add
FeedItems automatically; you'll probably just leave those alone in the
admin. Part of the standalone script should clear old FeedItems from
the database when you don't need them anymore.
E
see ya
sebey