Hello guys now i have a 1 question. I want to let my page visitors can order products by 4 options (ex: order by name asc or name desc) . Here is my html codes:
< select class=“custom-select custom-select-xs” name=‘orderby’>
< option value=“nameaz” selected>Ürün Koduna Göre A-Z< /option>
< option value=“nameza”>Ürün Koduna Göre Z-A< /option>
< option value=“draweraz”>Çekmece Sayısına Göre Artan< /option>
< option value=“drawerza”>Çekmece Sayısına Göre Azalan< /option>
</ select>
and when i searching on the internet i saw a man did in forms.py this and i did too (But i didn’t understand compleatly):
class OrderForm(forms.Form):
Order_CHOICES = (
(‘nameaz’, ‘Urun_Kodu’), (‘nameza’, ‘-Urun_Kodu’),
(‘draweraz’, ‘Cekmece_Sayisi’), (‘drawerza’, ‘-Cekmece_Sayisi’),)
orderby = forms.ChoiceField(choices = Order_CHOICES)
And now i dont know how to do on views.py
But also i’m using the pagination of django like this:
paginator = Paginator(productlist, 9)
page_number = request.GET.get(‘page’,1)
page = paginator.get_page(page_number)
I hope someone can find a solution with working with django pagination system.
Last little question: I also want to let visitors to filter by themself. (ex: i want to see only black products and products who have 2 drawer). Is it possible and solution of my first question and second question is similiar? (I couldn’t find anything when i write django filtering on google, i only see template filters)