2👍
✅
request.method
is a string (you just tested if it is equal to "POST"
in the first if
statement)!
Did you meant to test against request.POST['usubmit']
instead?
The line:
if request.method['usubmit'] == 'new':
will throw an error, but perhaps you wanted:
if request.POST['usubmit'] == 'new':
instead. Moreover, the lines:
else:
request.method['usubmit'] == 'Update'
don’t do what you think they do. You probably wanted to test if usubmit
is equal to 'Update'
for the second block:
elif request.POST['usubmit'] == 'Update':
Source:stackexchange.com