My trouble is the following code
CreateView.py
# Add new function
def error_display(self, message)
context={
'message':message,
}
return render(self.request, 'error.html', context)
#I modified form_valide function
def form_valide(self, form)
.......
try:
3<5 #True
except:
self.error_dispaly('error1')
else:
.......
if 3<5 #True
self.error_display('OK')
return render(self.request, passed.html, {message:'error2'})
Despite 「If」indicate "True", this view render passed.html(displaying 'error2'), but not 'OK' message (「If」seem not to work)
On the other hand,「If」do work with no function (the following code)
if 3<5 #True
context={msg:'OK'}
return render(self.request, error.html, context)
return render(self.request, passed.html, {message:'error2'})
This view render error.html(displaying 'OK')
I want to use 「error_display」function
Does anybody tell me Why the function disable 「If」
Django==3.2.8