Closed akoumjian closed 10 years ago
Thanks for the report. If I'm reading you right, I think the solution is to iterate over A, then run reposition on the related B query sets.
for a in A.objects.all():
B.objects.filter(a=a).order_by( ... ).reposition()
The way you're trying to do it actually makes a lot of sense, but the current implementation is pretty simplistic and doesn't take collections into account. Maybe it should.
I could be misunderstanding what the expected behavior is. My Model B has an FK to Model A. I have added a position field to Model B, which uses the Model A FK as the collection argument.
I create and run the migration, and all the fields have a default value of -1 (it makes sense that these would not be correct immediately after the migration.
At this point I use the ModelA.objects.reposition(), using the PositionManager. After it runs, the first set of Model B's are correctly positioned as 0, 1, 2. However, all the other Model B sets appears to be set to the same number. That number appears to be equal to what should be the highest number in the set. ie: If the set has 6 model B instances, they will all have a position of 5.
Iterating through the instances and attempting to save one object out of each set also appears to not fix anything.