Mohamed Feddad

57%
Flag icon
class ClassBasedFormView(generic.View):     template_name = 'form.html'       def get(self, request):         form = PersonDetailsForm()         return render(request, self.template_name, {'form': form})       def post(self, request):         form = PersonDetailsForm(request.POST)         if form.is_valid():             # Success! We can use form.cleaned_data now             return redirect('success')         else:             # Invalid form! Reshow the form with error highlighted             return render(request, self.template_name,                           {'form': form})
Mohamed Feddad
Creating a generic form view
Django Design Patterns and Best Practices: Industry-standard web development techniques and solutions using Python, 2nd Edition
Rate this book
Clear rating