#33959: Missing import in "Expressions can reference transforms" section
-----------------------------------------+------------------------
Reporter: Eido Askayo | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 4.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
In section [
https://docs.djangoproject.com/en/4.0/topics/db/queries /#expressions-can-reference-transforms Expressions can reference
transforms], the following code is shown:
{{{
>>> Entry.objects.values('pub_date__year').annotate(
... top_rating=Subquery(
... Entry.objects.filter(
... pub_date__year=OuterRef('pub_date__year')
... ).order_by('-rating').values('rating')[:1]
... ),
... total_comments=Sum('number_of_comments'))
}}}
There are missing imports for {{{Subquery}}}, {{{OuterRef}}} and {{{Sum}}}
functions:
{{{
>>> from django.db.models import Subquery, OuterRef, Sum
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33959>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.