Commit ce5ad819 authored by Alex Gaynor's avatar Alex Gaynor
Browse files

Merge pull request #1980 from krallin/patch-1

Add missing commas in Prefetch docs
parents a739573e 957d22b8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -956,14 +956,14 @@ This allows prefetching the same relation multiple times with a different
    >>> vegetarian_pizzas = Pizza.objects.filter(vegetarian=True)
    >>> Restaurant.objects.prefetch_related(
    ...     Prefetch('pizzas', to_attr('menu')),
    ...     Prefetch('pizzas', queryset=vegetarian_pizzas to_attr='vegetarian_menu'))
    ...     Prefetch('pizzas', queryset=vegetarian_pizzas, to_attr='vegetarian_menu'))

Lookups created with custom ``to_attr`` can still be traversed as usual by other
lookups:

    >>> vegetarian_pizzas = Pizza.objects.filter(vegetarian=True)
    >>> Restaurant.objects.prefetch_related(
    ...     Prefetch('pizzas', queryset=vegetarian_pizzas to_attr='vegetarian_menu'),
    ...     Prefetch('pizzas', queryset=vegetarian_pizzas, to_attr='vegetarian_menu'),
    ...     'vegetarian_menu__toppings')

Using ``to_attr`` is recommended when filtering down the prefetch result as it is