August 2016
Beginner to intermediate
717 pages
15h 24m
English
The DeleteView CBV can easily delete a record. It does not save a lot of time compared to a normal view, but it cannot be burdened with unnecessary views. We will show an example of task deletion. For this, we need to create the DeleteView.py file in the views/cbv module. Indeed, we need to override it because we will enter the name of the URL that we want to redirect. We can only put the URL in success_url, but we want our URL to be as DRY as possible. We will add the following code in the DeleteView.py file:
from django.core.urlresolvers import reverse from django.views.generic import DeleteView from TasksManager.models import Task class Task_delete(DeleteView): model = Task template_name = 'en/public/confirm_delete_task.html' ...
Read now
Unlock full access