[Django]-Django read radio value from a normal form

4πŸ‘

βœ…

You are selecting by name, so the first element with the name β€˜pri’ is selected, which will always be the label element with the name β€˜pri’ and a value of 1. The name of the label should be different to the name of the input element.

πŸ‘€CJ4

1πŸ‘

I think you can get the result like this:

meta['pri'] = bool(request.POST.get('pri')=='1')
πŸ‘€Ryan

0πŸ‘

Only solution for this is using onclick event on radio button and writing to hidden input with another name, then working with this input in views

πŸ‘€user2056721

Leave a comment