[Tutor] using a for loop with feedparser

Tonu Mikk tmikk at umn.edu
Tue Jan 27 16:28:47 CET 2009


Kent, you are absolutely correct.  I did not need the line number 5 at 
all.   This was my first  program that addressed a "real life" 
scenario.  I am excited that it worked.

Thank you,
Tonu

Kent Johnson wrote:
> 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
>   


-- 
Tonu Mikk
Educational Technology Consultant
Digital Media Center - dmc.umn.edu
tmikk at umn.edu 612 625-9221



More information about the Tutor mailing list