Redirect or 404

Report a typo

The service we're creating is used for TODO lists. Implement the delete method for removing tasks.

The name of a task is passed in a query as a parameter todo. Remove this task from all_todos list if it's present.

If the task is not present in the list, raise the Http404 exception; in other case, return a redirection to the "/" page.

Write a program in Python 3
from django.shortcuts import redirect, Http404
from django.views import View


class TodoView(View):
all_todos = []

def delete(self, request, todo, *args, **kwargs):
...
___

Create a free account to access the full topic