Django.fun

Класс DeletionMixin (Django 1.11)

from django.views.generic.edit import DeletionMixin

A mixin providing the ability to delete objects

Диаграмма | Documentation | Исходный код

Потомки

Атрибуты

  Определено в
success_url = None DeletionMixin

Методы

Calls the delete() method on the fetched object and then
redirects to the success URL.
257
258
259
260
261
262
263
264
265
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)
271
272
273
274
275
276
def get_success_url(self):
    if self.success_url:
        return self.success_url.format(**self.object.__dict__)
    else:
        raise ImproperlyConfigured(
            "No URL to redirect to. Provide a success_url.")
268
269
def post(self, request, *args, **kwargs):
    return self.delete(request, *args, **kwargs)