{{{
initial_queryset = MyObject.objects.filter(...)
filtered_queryset = initial_queryset.exclude(related_model__id__in=...)
for_loop_on_filtered = [MyOtherModel(some_id=..., other_id=...) for x in
filtered_queryset]
MyOtherModel.objects.bulk_create(for_loop_on_filtered)
filtered_queryset.update(processed=True) # silent failure to update
}}}
Fails to update all objects in `filtered_queryset`. It seems like the
reason is the list-comprehension on `filtered_queryset`.
I've been with Django for >6 years and this is by far the most surprising
behavior I've seen.
It does seem to be documented (?):
"You cannot call update() on a QuerySet that has had a slice taken or can
otherwise no longer be filtered."
But the fact is I can and did call `update()` on that QuerySet, and Django
returned 0 errors.
If that is the intended behavior, then I suggest updating the
documentation.
--
Ticket URL: <https://code.djangoproject.com/ticket/33841>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => worksforme
Comment:
Thanks for the report, however it works for me. Maybe in
`initial_queryset` you filter out conditions that don't match any rows
after adding `MyOtherModel` instances, it's hard to tell. Please use one
of
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
support channels] to debug your issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/33841#comment:1>