I have a case where I want to use radio buttons as my query option so I can get correct query set according to selected radio button. I can not find a way to get selected radio button value in form. There are a lot of info about using form class. what about simple html form. part of form is:
<label for="house-all-id">All</label>
<input type="radio" id="house-all-id" name="h-type" value="0"/>
<label for="house-orp-id">Just case one</label>
<input type="radio" id="house-orp-id" name="h-type" value="1"/>
<label for="house-inm-id">Just case two</label>
<input type="radio" id="house-inm-id" name="h-type" value="2"/>
These radio-buttons are part of a from with another widgets to help my get correct QuerySet. In view:
h_type = request.POST.get('h_type')
This returns a none-type object. How can I get value of selected radio button?
Your fields are named "h-type" but you're trying to access "h_type".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With