dimanche 25 juillet 2021

Checkbox inside the "for" (loop), Django

my checkbox html :

<form method="GET">
    
<button type="submit" class="btn btn-primary w-100 mt-3">Filter!</button>
</form>

it work correctly to make filter. views :

subcatid = request.GET.getlist('subcategory')

query string:

?subcategory=5&subcategory=6

it can be one or more than one, depends on number of subcategories. but when I go next page i suppose it become like :

?page=2&subcategory=5&subcategory=6

but it remove earliest subcategory i choose and keep the last one, just one, like :

?page=2&subcategory=5

acutely when i put Manually ?page=2&subcategory=5&subcategory=6 in url field it works but not from pagination buttons.

so while all checkboxes in filter has same names, name="subcategory" i made them unique by changing to name="", now each checkbox has unique name, now after tapping next page, Everything is kept, and there is no problem like before, but in views, I don't know how to get them with deafferents names

subcatid = request.GET.getlist('subcategory')  



Aucun commentaire:

Enregistrer un commentaire