Ticket #14757: 14757.diff

File 14757.diff, 1009 bytes (added by John Paulett, 13 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.  
    786786
    787787            SELECT * FROM blog_entry WHERE id IN (3, 4, 5, 20);
    788788
     789        Example with ``tables``::
     790
     791            Entry.objects.extra(tables=['blog_blog'], where=["name='Beatles Blog'"])
     792
     793        ...translates (roughly) into the following SQL::
     794
     795            SELECT blog_entry.* FROM blog_entry, blog_blog WHERE name='Beatles Blog';
     796
     797        In the previous case, a more portable solution would be to simply use ``filter()``::
     798
     799            Entry.objects.filter(blog__name='Beatles Blog')
     800
    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