On Sun, May 27, 2012 at 6:05 PM,  <[email protected]> wrote:

> To get a queryset containing all the objects where field == other_field
> should be something like the following:
>
> from django.db.models import F
>
> Amounts.objects.filter(field = F("other_field"))
>
> to then update all those objects with "OTHER" as the value for field would
> be:
>
> Amounts.objects.filter(field = F("other_field")).update(field="OTHER")
>
> Note that this won't execute the "else" portion above, but as it is not
> making any change (field already equals field), I assume this isn't an
> issue.
>
You are great, sir.
Thank you.
The query successfully updated the field column as was required.

-- 
Sandeep Kaur
E-Mail: [email protected]
Blog: sandymadaan.wordpress.com

-- 
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