Task Reordering
Last updated
Last updated
To achieve TodoList Sortable perform the below instruction
Include the npm package(via cdn) in task_list.html
Include a script to perform the Sortable TodoList
Setting unique key for each task using HTML attribute called data-position="{{task.pk}}"
Define a hidden form to get the unique keys as input to perform task list to reordering in permanent.
To write a script to collect the actual unique keys of the tasks list:
For every drag and drop of task list, above function is invoked.
From the function, after collecting unique keys from the current todolist and store it in pos
list variable.
Getting collected unique keys using input tag
We cannot process the above form data in django so we have to create forms.py file
todo/forms.py
Now write a django view to process the reordering operation
Mapping the task-reordering url