The fastest way to update a bunch of records in a query set in Django

I have a query with several million records. I need to update a boolean, toggle it at the root, so that the values ​​in the database table are reset. What is the fastest way to do this?

I tried navigating through a set of queries and updating and saving each record, which obviously takes a lot of time? We need to do this very quickly, any suggestions?

+5
source share
2 answers

See the documentation :

Entry.objects.all().update(value= not F('value'))
+4
source

Actually, this did not work for me.

Following:

Entry.objects.all().update(value=(F('value')==False))

0
source

All Articles