Opened 5 years ago

Closed 5 years ago

#32830 closed Bug (invalid)

The 'last' filter in django template default tags give negative index error

Reported by: sushantg2001 Owned by: sushantg2001
Component: Template system Version: 3.2
Severity: Normal Keywords: last django-template
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The 'last' filter in django template default tags give negative index error. This is because the code uses negative indexing to get the value which are not supported by RelatedManager querysets

Change History (2)

comment:1 by sushantg2001, 5 years ago

Owner: changed from nobody to sushantg2001
Status: new → assigned

comment:2 by Mariusz Felisiak, 5 years ago

Resolution: → invalid
Status: assigned → closed

The last template filter is not intended to work with a queryset but with a list, see ​docs. You can use {{ queryset.last }}, which will call ​QuerySet.last().

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