I have a QuerySet returned by a call like this

foos = Foo.objects.filter(id__in = [1, 2, 3])

Now I want to update each of these elements' attributes to a specific
value. What I need to do is some thing like,

for foo in foos:
    foo.price = 0
    foo.save()

But this would make as many database hits as elements in my QuerySet.
If I were using a raw sql I could have written some thing like
update foo set price = 0 whede id in (1, 2, 3)
with one database hit. How can I do the same in django, wichout
writing custom sql?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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