24👍
✅
The Python docs are your friend:
if request.POST.get('check', False):
...do stuff...
You could also do this (more Python docs):
if "check" in request.POST:
... do stuff...
0👍
This is what I did:
request.POST.get('field_name', '') == 'on'
Note: another proposed solution
request.POST.get('check', False) # do not use it
led to this error for me:
['“on” value must be either True or False.']
when the checkbox is selected.
- Django-allauth HTML email not send
- ERROR: Invalid HTTP_HOST header: '/webapps/../gunicorn.sock'
- Configure Django-rest
- Django template object type
- How to debug Django custom management command using VS Code
Source:stackexchange.com