Coffee hasn't kicked in yet...I figured it out about 5 minutes after
asking... and was about to post back the same thing!  Thanks!

On Mar 9, 9:47 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2007-03-09 at 14:39 +0000, [EMAIL PROTECTED] wrote:
> > Pehraps I'm doing something wrong here.  I should mention I am using
> > the multiple-database branch, so perhaps it's a bug...but thought I'd
> > check if my syntax is correct.
>
> > I'm trying to trim down the data returned from a query to speed things
> > up, as I only need three fields for this particular piece.
>
> > My code is:
>
> >         userids = list([(field.user_id) for field in userroles])
> >         if len(userids) >0:
> >                 allobligors =
> > UserInfo.objects.filter(user_id__in=userids).values('user_id',
> > 'first_name','last_name')
> >         else:
> >                 allobligors = None
>
> >         if allobligors:
> >            obligors  = [(obj.user_id, obj.last_name + ", " +
> > obj.first_name) for obj in allobligors] ## errors on this line
> >            noneobj = ('','')
> >            obligors.insert(0,noneobj)
> >         else:
> >            obligors = [('','')]
>
> > ( This works without the .values clause... all the properties are
> > correct )
>
> > The error I'm getting is:
> >           dict' object has no attribute 'user_id'
>
> The .values() method returns a list of dictionaries, not a QuerySet
> (which looks like a sequence of objects). So you need to change things
> like obj.user_id to obj["user_id"] in the values() case.
>
> Regards,
> Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to