formview api

Solutions on MaxInterview for formview api by the best coders in the world

showing results for - "formview api"
Emelie
21 Oct 2017
1from myapp.forms import ContactForm
2from django.views.generic.edit import FormView
3
4class ContactView(FormView):
5    template_name = 'contact.html'
6    form_class = ContactForm
7    success_url = '/thanks/'
8
9    def form_valid(self, form):
10        # This method is called when valid form data has been POSTed.
11        # It should return an HttpResponse.
12        form.send_email()
13        return super().form_valid(form)
14