diff --git a/todoApp/db.sqlite3 b/todoApp/db.sqlite3 index 53d38687..6af889a9 100644 Binary files a/todoApp/db.sqlite3 and b/todoApp/db.sqlite3 differ diff --git a/todoApp/todos/templates/todos/index.html b/todoApp/todos/templates/todos/index.html index 2142cfef..8f710b97 100644 --- a/todoApp/todos/templates/todos/index.html +++ b/todoApp/todos/templates/todos/index.html @@ -6,23 +6,22 @@ {% block content %} - {% if todo_list %} -
-
- {% for todo in todo_list %} -
-
-
-
{{ todo.title }}
-

{{ todo.description }}

- Edit -
-
-
- {% endfor %} +{% if todo_list %} +
+ {% for todo in todo_list %} +
+
+
+
{{ todo.title }}
+

{{ todo.description }}

+ Edit + Delete +
- {% else %} -

No todos as of now

- {% endif %} + {% endfor %} +
+{% else %} +

No todos as of now

+{% endif %} {% endblock %} diff --git a/todoApp/todos/urls.py b/todoApp/todos/urls.py index 4db747d8..3e2c69a1 100644 --- a/todoApp/todos/urls.py +++ b/todoApp/todos/urls.py @@ -5,5 +5,6 @@ urlpatterns = [ path('', views.IndexView.as_view(), name='index'), path('/edit', views.edit, name='edit'), - path('/save', views.save, name='save') + path('/save', views.save, name='save'), + path('/delete', views.delete, name='delete') ] \ No newline at end of file diff --git a/todoApp/todos/views.py b/todoApp/todos/views.py index 9497327f..da09dd86 100644 --- a/todoApp/todos/views.py +++ b/todoApp/todos/views.py @@ -22,6 +22,11 @@ def save(request, todo_id): todo.description = description todo.save() + return redirect('todos:index') + +def delete(request, todo_id): + todo = get_object_or_404(Todo, pk=todo_id) + todo.delete() return redirect('todos:index')