Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Mayur Pande
PLUS
Mayur Pande
Courses Plus Student 11,711 Points

How would I go about storing values of radio buttons in mysql using python

Hi,

So I have created a table in python which will have an id, a date and a tinyint for the value of a radio button.

I'm getting confused on how I would go about storing the value of the radio button in the db.

So in my code I would want four radio buttons with one set to default;

<form action="">
  <input type="radio" name="priority" value="one" checked> 1<br>
  <input type="radio" name="priority" value="two"> 2<br>
  <input type="radio" name="priority" value="three"> 3<br>
 <input type="radio" name="priority" value="Four">4<br> 

</form>

If I am using python flask, would this pick the default value up using the tinyint?

1 Answer

Well the request.POST will have the values that have been selected on the form.

Check This out for more info How to Get Data from flask request

create a view function to handle the request and set the form action='url_of_view_path' and method as POST