Browse Source

Updated README

tags/0.1
Johann Schmitz 4 years ago
parent
commit
0206d0694a
Signed by: ercpe <johann@j-schmitz.net> GPG Key ID: A084064277C501ED
1 changed files with 17 additions and 1 deletions
  1. +17
    -1
      README.md

+ 17
- 1
README.md View File

@@ -32,7 +32,23 @@ The `Query`'s `apply` method decides the best backend to use based on the type o

The most universal backend is the `ObjectsBackend`. This backend applies the query to standard python objects.

The `DjangoBackend` will be used if the `iterable` argument of the `apply` method is a Django `QuerySet` or `Manager` instance and translates the `Query` object into a Django database query.
The `DjangoBackend` will be used if the `iterable` argument of the `apply` method is a Django `QuerySet` or `Manager` instance. The `DjangoBackend` translates the `Query` object into a Django database query:

class Person(models.Model):
first_name = models.CharField(...)
last_name = models.CharField(...)
age = models.PositiveIntegerField(...)

query = Parser().parse("first_name == 'Alice')
query.apply(Person.objects)
will result in a Django query roughly equivalent to

Person.objects.filter(first_name='Alice')

and a query like `first_name == 'Bob' or age > 20` in

Person.objects.filter(Q(first_name='Bob') | Q(age__gt=20))


## License


Loading…
Cancel
Save