Kaydet (Commit) bf49d9eb authored tarafından Benjamin Bach's avatar Benjamin Bach Kaydeden (comit) Tim Graham

Fixed #28815 -- Fixed ExtractYear imports in docs/ref/models/expressions.txt.

üst 9d1d3b2d
...@@ -721,7 +721,8 @@ computation. See :ref:`window-frames` for details. ...@@ -721,7 +721,8 @@ computation. See :ref:`window-frames` for details.
For example, to annotate each movie with the average rating for the movies by For example, to annotate each movie with the average rating for the movies by
the same studio in the same genre and release year:: 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( >>> Movie.objects.annotate(
>>> avg_rating=Window( >>> avg_rating=Window(
>>> expression=Avg('rating'), >>> expression=Avg('rating'),
...@@ -739,7 +740,8 @@ genre, and release year) by using three window functions in the same query. The ...@@ -739,7 +740,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 partition and ordering from the previous example is extracted into a dictionary
to reduce repetition:: 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 = { >>> window = {
>>> 'partition': [F('studio'), F('genre')], >>> 'partition': [F('studio'), F('genre')],
>>> 'order_by': ExtractYear('released').asc(), >>> 'order_by': ExtractYear('released').asc(),
...@@ -820,7 +822,8 @@ If a movie's "peers" are described as movies released by the same studio in the ...@@ -820,7 +822,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 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:: 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( >>> Movie.objects.annotate(
>>> avg_rating=Window( >>> avg_rating=Window(
>>> expression=Avg('rating'), >>> expression=Avg('rating'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment