# Django - Select-options using for order by

**URL:** <https://forum.djangoproject.com/t/django-select-options-using-for-order-by/5814>\
**Category:** Using Django\
**Created:** [December 23, 2020, 9:00am UTC](https://forum.djangoproject.com/t/django-select-options-using-for-order-by/5814 "2020-12-23T09:00:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![safakatar38](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/safakatar38/32/2738_2.png) [@safakatar38](https://forum.djangoproject.com/u/safakatar38)\
**Post date:** [December 23, 2020, 9:00am UTC](https://forum.djangoproject.com/t/django-select-options-using-for-order-by/5814/1 "2020-12-23T09:00:49Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 23, 2020, 1:52pm UTC](https://forum.djangoproject.com/t/django-select-options-using-for-order-by/5814/2 "2020-12-23T13:52:04Z")

</div>

This more has to do with applying filters to your query results. See [Retrieving specific objects with filters](https://docs.djangoproject.com/en/3.1/topics/db/queries/#retrieving-specific-objects-with-filters) and [Field lookups](https://docs.djangoproject.com/en/3.1/ref/models/querysets/#field-lookups), along with the rest of the information on those two pages.

---

<div class="post-metadata">

**Author:** ![safakatar38](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/safakatar38/32/2738_2.png) [@safakatar38](https://forum.djangoproject.com/u/safakatar38)\
**Post date:** [December 23, 2020, 2:48pm UTC](https://forum.djangoproject.com/t/django-select-options-using-for-order-by/5814/3 "2020-12-23T14:48:45Z")

</div>

Mr ken as i see you are a good at django. If you know can you give response to my this question:  
I’m making a multilangual site and i’m using 7 or 8 if elif endif in every template, like this:

> {% if ‘/tr/’ in request.path %} include something  
> {% elif ‘/en/’ in request.path %} include somethingelse

Am i doing something bad or every multilangual site’s done like this? or do i need to copy every template and change the word’s to second language?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 23, 2020, 3:49pm UTC](https://forum.djangoproject.com/t/django-select-options-using-for-order-by/5814/4 "2020-12-23T15:49:35Z")

</div>

Sorry, I have no experience with the multilingual facilities. I’m guessing there’s some way to do this more properly, but I wouldn’t know what it is.  
I’d also suggest that when you have a different question on a different topic, that you open a new conversation on that topic to make it more visible, rather than chaining it on to an existing conversation on a different topic.
