Code Monkey home page Code Monkey logo

tri.query's Introduction

https://travis-ci.org/TriOptima/tri.query.svg?branch=master http://codecov.io/github/TriOptima/tri.query/coverage.svg?branch=master

Warning

tri.query is end of life. It has been merged into iommi.

iommi is backwards incompatible but the porting effort should be fairly mild, the biggest changes are that show is now called include, Variable is renamed to Filter and plural is used consistently for containers (so variable__foo is filters__foo in iommi).

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>

simple_gui.png

After switching to the advanced mode:

advanced_gui.png

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

http://triquery.readthedocs.org

tri.query's People

Contributors

boxed avatar feffe avatar jlubcke avatar larserikh avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

pombredanne

tri.query's Issues

Variable.multi_choice_queryset broken

Variable.multi_choice_queryset always results in no filtering. It should result in a list of expressions, and you should be able to specify the logical joiner between them (AND or OR).

No way to search for null values

It should be possible to search for NULL values in the database. Maybe foo=null, and foo="null" is a search for the string null.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.