Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

None-type object returned for selected radiobutton

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?

like image 908
Naser Hamidi Avatar asked Jul 12 '26 22:07

Naser Hamidi


1 Answers

Your fields are named "h-type" but you're trying to access "h_type".

like image 56
Daniel Roseman Avatar answered Jul 14 '26 15:07

Daniel Roseman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!