* status: new => assigned
* needs_better_patch: 0 => 1
* owner: nobody => Iván Triviño
* has_patch: 0 => 1
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Old description:
> 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.aggregate(first_published_year=Min('pub_date__year'))
> }}}
> There is a missing import for {{{Min}}} function:
> {{{
> >>> from django.db.models import Min
> }}}
New description:
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.aggregate(first_published_year=Min('pub_date__year'))
}}}
There is a missing import for {{{Min}}} function:
{{{
>>> from django.db.models import Min
}}}
Also, 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
}}}
--
Comment:
Thanks for the report!
[https://github.com/django/django/pull/16005 PR]
Ticket is not required for such a small cleanups, by the way.
--
Ticket URL: <https://code.djangoproject.com/ticket/33958#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.