On Samstag, 10. Februar 2007, Ned Batchelder wrote:
> But is is simple to convert what you have into what you want:
>
> l =
> User.objects.filter(username__in=['foo','bar']).values('username', 'email')
> emails = dict([(d['username'], d['email']) for d in l])
>
> It would be a little simpler like this:
>
> emails = dict([(r.username, r.email) for r in
> User.objects.filter(username__in=['foo','bar'])])
>
> The dict() built-in accepts a number of forms of arguments. One is a
> list of pairs, each of which becomes a key and value in the resulting
> dictionary.
Nice! Thanks alot for posting posting this solution.
Best Regards,
Dirk Eschler
--
Dirk Eschler <mailto:[EMAIL PROTECTED]>
http://www.krusader.org
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---