diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index adce067eb0..fc1f0f81cd 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -169,7 +169,19 @@ Using a custom manager when traversing reverse relations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is now possible to :ref:`specify a custom manager -` when traversing a reverse relationship. +` when traversing a reverse relationship:: + + class Blog(models.Model): + pass + + class Entry(models.Model): + blog = models.ForeignKey(Blog) + + objects = models.Manager() # Default Manager + entries = EntryManager() # Custom Manager + + b = Blog.objects.get(id=1) + b.entry_set(manager='entries').all() New system check framework ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt index 2aa60be0b8..f53d1a9998 100644 --- a/docs/topics/db/queries.txt +++ b/docs/topics/db/queries.txt @@ -1155,11 +1155,19 @@ query you can use the following syntax:: class Entry(models.Model): #... - objects = models.Manager() # Default Manager - entries = EntryManager() # Custom Manager + objects = models.Manager() # Default Manager + entries = EntryManager() # Custom Manager - >>> b = Blog.objects.get(id=1) - >>> b.entry_set(manager='entries').all() + b = Blog.objects.get(id=1) + b.entry_set(manager='entries').all() + +If ``EntryManager`` performed default filtering in its ``get_queryset()`` +method, that filtering would apply to the ``all()`` call. + +Of course, specifying a custom reverse manager also enables you to call its +custom methods:: + + b.entry_set(manager='entries').is_published() Additional methods to handle related objects ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~