How to work with checkboxes and django?

I would like to retrieve column data from a table after checking the desired checkboxes. Could you please help?
Below I would like to present my code below. In checkbox.html and views.py I don’t know exactly how to retrieve data from the table after seting the checkboxes.

startapp/urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('checkbox/', views.checkbox, name='checkbox'),
    path('', views.home1, name='home1'),

]

startapp/views.py

def home1(request):
    patients = Patients.objects.all()
    context = {
        'patients': patients
    }
    if request.method == 'post':
        s = request.POST.getlist('s')
        print(s)
    return render(request, 'home1.html', context)


def checkbox(request):
    patients = Patients.objects.all()
    context = {
        'patients': patients
    }
#Here I have to put any code for connection with checkbox.html
    return render(request, 'home1.html', context)

startproj/urls.py

from django.contrib import admin
from django.urls import path, include
from django.views.generic.base import TemplateView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('startapp.urls')),
]

home1.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
Checkboxes will take the information from the table columns!<form action="" method="post">
    {% csrf_token %}
    <input type="checkbox" name="s" value="name">Name
    <br><br>
    <input type="checkbox" name="s" value="years">Years
    <br><br>
    <input type="checkbox" name="s" value="apress">Arterial Pressure
    {% csrf_token %}
    <button type="submit">submit</button>
</form>

<div class="container">
        <div class="row mt-4">
            <div class="col">
                <table class="table">
                    <thead class="thead-dark">
                        <tr>
                            <th scope="col">PatientID</th>
                            <th scope="col">Name</th>
                            <th scope="col">Years</th>
                            <th scope="col">Probe Date</th>
                            <th scope="col">Birth Date</th>
                            <th scope="col">Arterial Pressure</th>
                        </tr>
                    </thead>
                    <tbody>
                    {% for patient in patients %}
                        <tr>

                            <td>{{ patient.patient_id }}</td>
                            <td>{{ patient.name }}</td>
                            <td>{{ patient.years }}</td>
                            <td>{{ patient.probe_date }}</td>
                            <td>{{ patient.birth_date }}</td>
                            <td>{{ patient.arterial_pressure }}</td>
                        </tr>
                    {% endfor %}
                    </tbody>

                </table>
            </div>
        </div>
    </div>
<p>More data here! The page is under construction!</p>
<a href="{% url 'checkbox' %}">Checkboxes result</a>

</body>
</html>

checkbox.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="" method="post">

#if checkbox[‘name’].is_checked:
#take date from the column[name]
#if checkbox[‘years’].is_checked:
#take date from the column[years]
#if checkbox[‘name’].is_checked and :checkbox[‘years’].is_checked
#take date from the column[name] and column[years]

</form>

</body>
</html>

Is this related to your other post at How to select desired table column??

If so, do you need to send the data back, or do you just need to submit the values of the selection, knowing that you have the data on the server?

If you really do need to send the data back, then you would need to write some JavaScript to inspect the tables and extract the values, submitting that in the request.

Otherwise, I suggest you only send back the checkbox values and perform the data retrieval on the server, using the same queries as what produced the original table, but using the checkboxes to identify what data elements to use.

Thank you for your answer! I would like to take the data column selected from the corresponding checkbox as list. Then I would like to use the data for calculations!

Ok, but do you need to send that data back to the server? Can you rerun the original query on the server to get that data?

I don’t need to send that data back to the server!