I have a formView
class as you can see below:-
view.py
class ThreadForm(FormView):
template_name = 'thread.html'
form_class = ThreadModelForm
success_url = '/success'
def form_valid(self, form):
# This method is called when valid form data has been POSTed.
# It should return an HttpResponse.
print form.cleaned_data
return super(ThreadForm, self).form_valid(form)
def get_context_data(self, **kwargs):
context = super(ThreadForm, self).get_context_data(**kwargs)
context['second_form'] = MessageModelForm
return context
thread.html
{form.as_p}
{second_form.as_p}
SUBMIT
In my template thread.html
, I have two modelforms but single submit button. The problem is I am not getting any data from my second_form
and not able validate second_form
as well. I am receiving data from form
but not from second_form
. Could anyone tell me how to validate second_form
data. Thank you
One method is to use request.post['data']
but is there any other method there?