I'm looking for getting table row value thanks to checkbox
but I don't overcome to get variables according to selected checkbox. I have to add - I'm new with CBV !
This is my template.html :
<table class="table table-bordered table-striped table-condensed table_model" style="width: 160%;">
<thead>
<tr>
<th style="width: 10%;">Choice</th>
<th>Document title</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
In my main.py file (similar to views.py file)
class Document(View):
template_name = 'doc_form.html'
form_class = DocumentForm
success_url = 'doc_form.html'
def get(self, request):
form = self.form_class()
query_document = None
query_document_updated = None
if "SearchOMCL" in request.GET:
... some things ...
checkbox_id = request.POST.getlist('DocumentChoice')
print(checkbox_id)
context = {
'form': form,
'query_document' : query_document,
'query_document_updated' : query_document_updated
}
return render(request, self.template_name, context)
I don't overcome to get a list of values when my checkbox is selected. I have to add someting else ?
Aucun commentaire:
Enregistrer un commentaire