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

Calls the delete() method on the fetched object and then
redirects to the success URL.
245
246
247
248
249
250
251
252
253
def delete(self, request, *args, **kwargs):
    """
    Calls the delete() method on the fetched object and then
    redirects to the success URL.
    """
    self.object = self.get_object()
    success_url = self.get_success_url()
    self.object.delete()
    return HttpResponseRedirect(success_url)

def get_success_url(self): DeletionMixin

259
260
261
262
263
264
def get_success_url(self):
    if self.success_url:
        return self.success_url % self.object.__dict__
    else:
        raise ImproperlyConfigured(
            "No URL to redirect to. Provide a success_url.")

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

256
257
def post(self, request, *args, **kwargs):
    return self.delete(request, *args, **kwargs)