Home > Software engineering >  django kanban type board sorting at volume
django kanban type board sorting at volume

Time:07-13

I have a django app with tasks stored in a database, similar to a kanban board type layout and each record has a column and order for where they are in the list.

The problem is this list can get to hundreds or thousands of records in one column, on changing column based on where the user places the card the column is updated and order is recalculated/set for all records in that column.

Is there a more efficient way than a heavy process updating thousands of records to set order?

CodePudding user response:

I would suggest to use the F functionality from Django to update all objects in a queryset with arithmetic value rule

Something like:

Model.objects.filter(…).update(order=F('order') - 1)

https://docs.djangoproject.com/en/4.0/ref/models/expressions/

A more complex but smart answer: https://stackoverflow.com/a/72894011/10992051

CodePudding user response:

You will want to use bulk_update to more efficiently update your records en-masse:

https://docs.djangoproject.com/en/4.0/ref/models/querysets/#bulk-update

  • Related