[Answered ]-Associate radio buttons with table rows in Django

2👍

Pandas has an insert function you can use to add a column to the generated table. I don’t know what you’re using to id your individual rows, but let’s say we use the values in column A, you can run through the rows.

radio = [] # empty array to push the rows of input tags 
for val in dumy_df.['A']:
    radio.append('<input type="radio" value="{}">'.format(val))

So you could try dumy_df.insert(0, 'E', radio , allow_duplicates=True)

0, being the location, radio being html for the radio button like

Then you could wrap the whole table in a form tag.

<form action="/some_link/" method="post">
  <div class="table-responsive">
     {{ table1 | safe }}
   </div>
</form>

I haven’t tried this in entirety, but something along these lines might work.

Edit2: Okay, see above.

👤onyeka

Leave a comment