Django select filter

30 views
Skip to first unread message

sum abiut

unread,
Sep 12, 2017, 7:43:48 PM9/12/17
to django...@googlegroups.com
Hi,
I am working on an app which has a dropdown/select option which contain months of the year. What i want to accomplished is when the user click on the drop down and select a particular  month of the year the app should display a table filter by that particular   selected month.  


Please point me to the right direction to get me started.

cheer

Oladipupo Elegbede

unread,
Sep 12, 2017, 8:10:47 PM9/12/17
to django...@googlegroups.com
I think the filtering should be done in your view.
You pass the value of the selected month to the view as a post item.

Then do a query based on the view.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y5JQoekZfW%3DymeNJHyXQj6ExJHweENW2gAfQiBhnXg6%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

ADEWALE ADISA

unread,
Sep 12, 2017, 9:15:17 PM9/12/17
to django...@googlegroups.com

you can make it interesting by using ajax to post the selected month to your view which u ve already written to accept the month variable. use the variable to filter the necessary queryset in your view, then return the response in json format. you can now collect it from your ajax response, use javascript to dynamically update your table.

--

sum abiut

unread,
Sep 13, 2017, 12:07:41 AM9/13/17
to django...@googlegroups.com
I am trying to understand this code. Can someone explain where the current_org came from

code taken from stackoverflow

{% for org in organisation %}
   <option value="{{org.id}}"
       {% if org == current_org %}selected="selected"{% endif %}>
       {{org.name|capfirst}}
   </option>
{% endfor %}


cheers


Bernd Wechner

unread,
Sep 13, 2017, 12:26:23 AM9/13/17
to Django users
Reply all
Reply to author
Forward
0 new messages