Example #1
0
    def post(self, request, pk):
        type = get_object_or_404(self.model, pk=pk)
        form = TypeForm(request.POST, instance=type)
        if not form.is_valid():
            ctx = {'form': form}
            return render(request, self.template, ctx)

        form.save()
        return redirect(self.success_url)
Example #2
0
    def post(self, request):
        form = TypeForm(request.POST)
        if not form.is_valid():
            ctx = {'form': form}
            return render(request, self.template, ctx)

        type = form.save()
        return redirect(self.success_url)