tri.query¶
tri.query makes it easy to implement searching and filtering in your Django app.
Major features:
- Generate simple filtering GUIs easily while at the same time:
- Supply your views with advanced query languages
- Query language can be used stand alone without the GUI parts
- Highly customizable GUI based on tri.form
Example¶
Simple view that allows the user to search for a car by choosing the make from a drop down, and search for specific model in the advanced mode:
class CarQuery(Query):
make = Variable.choice(
choices=['Toyota', 'Volvo', 'Ford'],
form_field__show=True) # Display this field in the simple style GUI
model = Variable.text()
def cars(request):
query = CarQuery()
cars_query_set = query.request_to_q(request)
form = query.form()
return render(
template_name='cars.html',
context_instance=RequestContext(request, {'query_form': form, 'cars': cars_query_set}))
<!-- cars.html -->
{% include "tri_query/form.html" with form=query_form %}
<ul>
{% for car in cars %}
<li>{{ car }}</li>
{% endfor %}
</ul>
After switching to the advanced mode:
Programmatically call the search API:
query = CarQuery()
cars_query_set = query.parse('make=Toyota and (make=1991 or make=1992)')
Running tests¶
You need tox installed then just make test.
License¶
BSD
Documentation¶
Contents:¶
- Installation
- Usage
- API documentation
- History
- 6.3.0 (2020-03-09)
- 6.2.0 (2020-01-09)
- 6.1.0 (2019-10-14)
- 6.0.0 (2019-06-14)
- 5.0.2 (2019-05-03)
- 5.0.1 (2019-04-25)
- 5.0.0 (2019-04-12)
- 4.2.1 (2019-04-25)
- 4.2.0 (2019-04-01)
- 4.1.0 (2019-02-18)
- 4.0.4 (2018-10-23)
- 4.0.3 (2018-10-10)
- 4.0.2 (2018-10-04)
- 4.0.1 (2018-09-21)
- 4.0.0 (2017-08-22)
- 3.3.0 (2017-04-27)
- 3.2.0 (2017-03-22)
- 3.1.0 (2016-09-19)
- 3.0.0 (2016-09-14)
- 2.2.0 (2016-08-16)
- 2.1.1 (2016-08-08)
- 2.1.0 (2016-07-12)
- 2.0.0 (2016-06-02)
- 1.11.0 (2016-04-25)
- 1.10.0 (2016-04-21)
- 1.9.0 (2016-04-21)
- 1.8.0 (2016-04-19)
- 1.7.0 (2016-04-08)
- 1.6.0 (2016-03-03)
- Credits
- Contributing