Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#33958 closed Cleanup/optimization (fixed)

Missing imports in "Expressions can reference transforms" section.

Reported by: Eido Askayo Owned by: Iván Triviño
Component: Documentation Version: 4.0
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mariusz Felisiak)

In section 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

Change History (4)

comment:1 by Mariusz Felisiak, 20 months ago

Description: modified (diff)
Has patch: set
Owner: changed from nobody to Iván Triviño
Patch needs improvement: set
Status: newassigned
Summary: Missing import in "Expressions can reference transforms" sectionMissing imports in "Expressions can reference transforms" section.
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Thanks for the report!

PR

Ticket is not required for such a small cleanups, by the way.

comment:2 by Mariusz Felisiak, 20 months ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:3 by GitHub <noreply@…>, 20 months ago

Resolution: fixed
Status: assignedclosed

In 411a6ec:

Fixed #33958 -- Added imports to examples in "Expressions can reference transforms" section.

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 20 months ago

In 29fac6b6:

[4.1.x] Fixed #33958 -- Added imports to examples in "Expressions can reference transforms" section.

Backport of 411a6ec93a9b21e5ed1e9fc05b34f021288cd10c from main

Note: See TracTickets for help on using tickets.
Back to Top