I’ve tried these queries with these results:
queryset.update(done=not F('boolean'))
{'time': '0.001', 'sql': u'UPDATE "todo_item" SET "done" = True'}
queryset.update(done=(F('boolean')==False))
{'time': '0.001', 'sql': u'UPDATE "todo_item" SET "done" = False'}
What I would like is something like this:
queryset.update(done=F('done'))
{'time': '0.002', 'sql': u'UPDATE "todo_item" SET "done" = "todo_item"."done"'}
But with
SET "done" = !"todo_item"."done"
to toggle the boolean value
I am developing django-orm extension, and have already partially implemented the solution to your problem.
https://github.com/niwibe/django-orm
Is a partial solution and not very clean. And so far only for postgresql. In a while I’ll see how to improve it.
Update: now improved and works on postgresql, mysql and sqlite.