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

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

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