class DeletionMixin

from django.views.generic.edit import DeletionMixin
Hierarchy diagram Documentation Source code
A mixin providing the ability to delete objects

Attributes

  Defined in
success_url = None DeletionMixin
Expand Collapse

Methods

def delete(self, request, *args, **kwargs): DeletionMixin

212
213
214
215
def delete(self, request, *args, **kwargs):
    self.object = self.get_object()
    self.object.delete()
    return HttpResponseRedirect(self.get_success_url())

def get_success_url(self): DeletionMixin

221
222
223
224
225
226
def get_success_url(self):
    if self.success_url:
        return self.success_url
    else:
        raise ImproperlyConfigured(
            "No URL to redirect to. Provide a success_url.")

def post(self, *args, **kwargs): DeletionMixin

218
219
def post(self, *args, **kwargs):
    return self.delete(*args, **kwargs)