Answer the question
In order to leave comments, you need to log in
How to do something like Tb.objects.all()[:N].update(que=quie_id]) in Django?
In short, let's say there is a Django service that regularly, but relatively rarely, receives a bunch of data and distributes tasks among several other services that will process the data, put it in drives (and drives are finite), etc. Processing services work unevenly, some services have accumulated tasks from previous periods that have not yet been fired, and all this must be taken into account when distributing. When, the distribution service determines what, say, N
objects from the table should Tb
be distributed for processing to the service que=quie_id
, and here it is logical to apply the following construction:
Tb.objects.all()[:N].update(que=quie_id])
But Django cannot do update
by [:N]
. At the same time, N
it is quite large and it takes a long time to go through the entire queryset and change records one at a time. How to proceed to do a group update on a limited queryset?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question