I’m using a checkbox form in my template and in my view im trying to check if the box has been checked or not
I have the following code in my view:
if request.POST['check'] == True:
but then it throws an error if it is unchecked. How do i check if there is a value ‘check’ in my post data?
Thanks
The Python docs are your friend:
You could also do this (more Python docs):