I want to display both form1
and form2
on a web page. If form2
is filled (if success == True
), I want my view to not execute if form1.is_valid:
(which gives errors). How can I access the value of success
in views.py?
forms.py
class Form1(forms.Form):
....
....
def clean(self):
....
....
class Form2(forms.Form):
....
....
def clean(self):
....
success = False
views.py
def my_view(request, element_pk):
....
....
if request.method == POST:
form2 = Form2(request.POST)
form1 = Form1(request.POST)
if form2.is_valid():
....
if form1.is_valid():
....
else:
form2 = Form2()
form1 = Form1()