Ticket #14757: 14757.diff

File 14757.diff, 1009 bytes (added by John Paulett, 7 years ago)

Add example using both tables and where in Queryset.extra()

  • docs/ref/models/querysets.txt

    diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
    index badcf38..2996582 100644
    a b of the arguments is required, but you should use at least one of them. 
    787787            SELECT * FROM blog_entry WHERE id IN (3, 4, 5, 20);
     789        Example with ``tables``::
     791            Entry.objects.extra(tables=['blog_blog'], where=["name='Beatles Blog'"])
     793        ...translates (roughly) into the following SQL::
     795            SELECT blog_entry.* FROM blog_entry, blog_blog WHERE name='Beatles Blog';
     797        In the previous case, a more portable solution would be to simply use ``filter()``::
     799            Entry.objects.filter(blog__name='Beatles Blog')
    789801        Be careful when using the ``tables`` parameter if you're specifying
    790802        tables that are already used in the query. When you add extra tables
    791803        via the ``tables`` parameter, Django assumes you want that table included
Back to Top