#33958: Missing imports in "Expressions can reference transforms" section.
-------------------------------------+-------------------------------------
     Reporter:  Eido Askayo          |                    Owner:  Iván
         Type:                       |  Triviño
  Cleanup/optimization               |                   Status:  assigned
    Component:  Documentation        |                  Version:  4.0
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070182e7e3817c-d3044ae9-802d-4f5c-92e6-21b38b32fbd6-000000%40eu-central-1.amazonses.com.

Reply via email to