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)
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)