Task Reordering
#1. To Make TodoList Sortable by Using sortable.js NPM package.
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
#2 To make sortable TodoList permanent.
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 tagWe cannot process the above form data in django so we have to create forms.py file
todo/forms.pyNow write a django view to process the reordering operation
Mapping the task-reordering url
Last updated