[Tutor] using a for loop with feedparser

Kent Johnson kent37 at tds.net
Tue Jan 27 00:45:20 CET 2009


On Mon, Jan 26, 2009 at 4:53 PM, Tonu Mikk <tmikk at umn.edu> wrote:
> I now have a new question related to the same project.  I currently have a
> code snippet like this:
>
> 1.for item in d.entries:
> 2.    link = Link(url=item.link)
> 3.    link.save()
> 4.    user = User.objects.get(id=1)
> 5.    link = Link.objects.get(id=1)
> 6.    bookmark = Bookmark (
> 7.        title = item.title,
> 8.        desc = item.description,
> 9.        link = link,
> 10.      user = user,
> 11.  )
> 12.  bookmark.save()
>
> I need to increment the link id (line 5) for each item in the d.entries.  I
> tried "link = Link.objects.get(id=id+1)" and "link =
> Link.objects.get((id=1)+1)", but both of them generated errors.   I am not
> quite sure where to go from here.

Are you trying to retrieve the Link you just saved in line 3? Why not
just use the link variable you already have?

Kent


More information about the Tutor mailing list