[Fixed]-How to get the submitted value of a form in a Django class-based view?

25👍

You can check the form’s cleaned_data attribute, which will be a dictionary with your fields as keys and values as values. Docs here.

Example:

class myFormView(FormView):
    template_name = 'myTemplate.html'
    form_class = myForm
    success_url = "/blahblahblah"


    def form_valid(self, form):
        email = form.cleaned_data['email']  # <--- Add this line to get email value
        return super(myFormView, self).form_valid(form)
👤Alex

4👍

try this:

 form.cleaned_data.get('email')

Leave a comment