from django.shortcuts import (
    get_object_or_404, redirect, render)


class ObjectCreateMixin:
    form_class = None
    template_name = ''

    def get(self, request):
        return render(
            request,
            self.template_name,
            {'form': self.form_class()})

    def post(self, request):
        bound_form = self.form_class(request.POST)
        if bound_form.is_valid():
            new_object = bound_form.save()
            return redirect(new_object)
        else:
            return render(
                request,
                self.template_name,
                {'form': bound_form})


class ObjectUpdateMixin:
    form_class = None
    model = None
    template_name = ''

    def get(self, request, slug):
        obj = get_object_or_404(
            self.model, slug__iexact=slug)
        context = {
            'form': self.form_class(instance=obj),
            self.model.__name__.lower(): obj,
        }
        return render(
            request, self.template_name, context)

    def post(self, request, slug):
        obj = get_object_or_404(
            self.model, slug__iexact=slug)
        bound_form = self.form_class(
            request.POST, instance=obj)
        if bound_form.is_valid():
            new_object = bound_form.save()
            return redirect(new_object)
        else:
            context = {
                'form': bound_form,
                self.model.__name__.lower(): obj,
            }
            return render(
                request,
                self.template_name,
                context)

@@ -1,8 +1,53 @@
+from django.http import HttpResponseRedirect%0A
 from dja
@@ -664,24 +664,572 @@
 nd_form%7D)%0A%0A%0A
+class ObjectDeleteMixin:%0A    model = None%0A    success_url = ''%0A    template_name = ''%0A%0A    def get(self, request, slug):%0A        obj = get_object_or_404(%0A            self.model, slug__iexact=slug)%0A        context = %7B%0A            self.model.__name__.lower(): obj,%0A        %7D%0A        return render(%0A            request, self.template_name, context)%0A%0A    def post(self, request, slug):%0A        obj = get_object_or_404(%0A            self.model, slug__iexact=slug)%0A        obj.delete()%0A        return HttpResponseRedirect(%0A            self.success_url)%0A%0A%0A
 class Object

Implement ObjectUpdateMixin.