Browse Source

Updated README

Johann Schmitz 2 years ago
parent
commit
0206d0694a
Signed by: Johann Schmitz <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
32 32
 
33 33
 The most universal backend is the `ObjectsBackend`. This backend applies the query to standard python objects.
34 34
 
35
-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.
35
+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:
36
+
37
+	class Person(models.Model):
38
+		first_name = models.CharField(...)
39
+		last_name = models.CharField(...)
40
+		age = models.PositiveIntegerField(...)
41
+
42
+	query = Parser().parse("first_name == 'Alice')   
43
+    query.apply(Person.objects)
44
+    
45
+will result in a Django query roughly equivalent to
46
+
47
+	Person.objects.filter(first_name='Alice')
48
+
49
+and a query like `first_name == 'Bob' or age > 20` in
50
+
51
+	Person.objects.filter(Q(first_name='Bob') | Q(age__gt=20))
36 52
 
37 53
 
38 54
 ## License