Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRodrigo Muñoz
Courses Plus Student 20,171 PointsWhat is the best way for building query filters in Django?
I have something like this:
In the models.py not only Boolean fields but also a selectField, a charField and textField. At the time I'm trying to figure out how to build a proper query filter (including a blank value), in which, the user is the one who decides.
At the time I have seen some old answers to this problem but I'm not actually sure how to do it. The alternatives are:
- Using a class based filter like this (answer is from 2009):
Using raw queries in Django
Using Django Restful (allow to exclude empty values)
Using Django sessions (Need to figure out how first)
Have anyone experienced something similar?
1 Answer
Rodrigo Muñoz
Courses Plus Student 20,171 PointsIn order to answer this. I have found a reusable application inside Django:
http://django-filter.readthedocs.org/en/stable/index.html
We also need to use Django forms.
Can't wait for the next Django Course!
Chris Freeman
Treehouse Moderator 68,454 PointsChris Freeman
Treehouse Moderator 68,454 PointsMoved comment to Answer.