def post(self, request): form = DemoForm(request.POST) if form.is_valid(): form.save() return redirect('cbv') return HttpResponse('Error!')
def function_based_view(request): """ Function based views take a request and are very explicit in the actions. They have more code in some regards, but they go step by step in execution. """ form = DemoForm(request.POST or None) if request.method == 'POST': if form.is_valid(): form.save() return redirect('function') else: return HttpResponse('Error!') context = {'form': form} return render(request, 'my_template.html', context)