diff options
-rw-r--r-- | todolists/views.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/todolists/views.py b/todolists/views.py index 52987356..2931d9bb 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -86,6 +86,12 @@ def edit(request, list_id): packages = [p.pkg for p in todo_list.packages] + # first delete any packages not in the new list + for p in todo_list.packages: + if p.pkg not in form.clean_data['packages']: + p.delete() + + # now add any packages not in the old list for pkg in form.clean_data['packages']: if pkg not in packages: TodolistPkg.objects.create(list = todo_list, pkg = pkg) |