Code

Ticket #14757: querysets.txt.diff

File querysets.txt.diff, 979 bytes (added by BernhardEssl, 3 years ago)
Line 
1Index: docs/ref/models/querysets.txt
2===================================================================
3--- docs/ref/models/querysets.txt       (revision 16433)
4+++ docs/ref/models/querysets.txt       (working copy)
5@@ -786,6 +786,18 @@
6 
7             SELECT * FROM blog_entry WHERE id IN (3, 4, 5, 20);
8 
9+        Example with ``tables``::
10+
11+            Entry.objects.extra(tables=['blog_blog'], where=['name=%s'], params=['Beatles Blog'])
12+
13+        ...translates (roughly) into the following SQL::
14+
15+            SELECT blog_entry.* FROM blog_entry, blog_blog WHERE name='Beatles Blog';
16+
17+        In the previous case, a more portable solution would be to simply use ``filter()``::
18+
19+            Entry.objects.filter(blog__name='Beatles Blog')
20+
21         Be careful when using the ``tables`` parameter if you're specifying
22         tables that are already used in the query. When you add extra tables
23         via the ``tables`` parameter, Django assumes you want that table included