92👍
✅
Try this:
some_var = request.POST.getlist('checks')
some_var
will contain [1,3,4]
(those values that were checked)
40👍
This will fix your problem,
some_var = request.POST.getlist('checks[]')
If you write some_var = request.POST.getlist('checks')
may not work properly.
- [Django]-Django: OperationalError No Such Table
- [Django]-Writing a __init__ function to be used in django model
- [Django]-Django Cannot set values on a ManyToManyField which specifies an intermediary model. Use Manager instead
1👍
this is will work:
<input type="checkbox" name="checks[]" value="1" />
<input type="checkbox" name="checks[]" value="2" />
<input type="checkbox" name="checks[]" value="3" />
<input type="checkbox" name="checks[]" value="4" />
views.py
some_var = request.POST.getlist('checks[]')
- [Django]-What's the recommended approach to resetting migration history using Django South?
- [Django]-How to monkey patch Django?
- [Django]-Django logging of custom management commands
Source:stackexchange.com