diff options
| author | Benjamin Bach <benjaoming@gmail.com> | 2017-11-17 23:30:21 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-11-17 17:30:37 -0500 |
| commit | 385e06d8c05ad4e5089295a3bafad2b922fd2763 (patch) | |
| tree | 7dfdbb26371ac67dd32e3d3551fb4dfa13a1a0ea /docs/ref | |
| parent | 5b21e3983dfce04251dbb795a70859c1ee78db8e (diff) | |
[2.0.x] Fixed #28815 -- Fixed ExtractYear imports in docs/ref/models/expressions.txt.
Backport of bf49d9eb0b33aefc7179d3843fad0cb7df4e7790 from master
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/models/expressions.txt | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt index 88981198c2..13ed001a03 100644 --- a/docs/ref/models/expressions.txt +++ b/docs/ref/models/expressions.txt @@ -727,7 +727,8 @@ computation. See :ref:`window-frames` for details. For example, to annotate each movie with the average rating for the movies by the same studio in the same genre and release year:: - >>> from django.db.models import Avg, ExtractYear, F, Window + >>> from django.db.models import Avg, F, Window + >>> from django.db.models.functions import ExtractYear >>> Movie.objects.annotate( >>> avg_rating=Window( >>> expression=Avg('rating'), @@ -745,7 +746,8 @@ genre, and release year) by using three window functions in the same query. The partition and ordering from the previous example is extracted into a dictionary to reduce repetition:: - >>> from django.db.models import Avg, ExtractYear, F, Max, Min, Window + >>> from django.db.models import Avg, F, Max, Min, Window + >>> from django.db.models.functions import ExtractYear >>> window = { >>> 'partition': [F('studio'), F('genre')], >>> 'order_by': ExtractYear('released').asc(), @@ -826,7 +828,8 @@ If a movie's "peers" are described as movies released by the same studio in the same genre in the same year, this ``RowRange`` example annotates each movie with the average rating of a movie's two prior and two following peers:: - >>> from django.db.models import Avg, ExtractYear, F, RowRange, Window + >>> from django.db.models import Avg, F, RowRange, Window + >>> from django.db.models.functions import ExtractYear >>> Movie.objects.annotate( >>> avg_rating=Window( >>> expression=Avg('rating'), |
