[Django] #32830: The 'last' filter in django template default tags give negative index error

11 views
Skip to first unread message

Django

unread,
Jun 8, 2021, 9:56:16 PM6/8/21
to django-...@googlegroups.com
#32830: The 'last' filter in django template default tags give negative index error
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
sushantg2001 |
Type: Bug | Status: new
Component: Template | Version: 3.2
system | Keywords: last django-
Severity: Normal | template
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/32830>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 8, 2021, 10:00:02 PM6/8/21
to django-...@googlegroups.com
#32830: The 'last' filter in django template default tags give negative index error
-------------------------------------+-------------------------------------
Reporter: sushantg2001 | Owner:
| sushantg2001
Type: Bug | Status: assigned
Component: Template system | Version: 3.2
Severity: Normal | Resolution:
Keywords: last django- | Triage Stage:
template | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by sushantg2001):

* owner: nobody => sushantg2001
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32830#comment:1>

Django

unread,
Jun 9, 2021, 1:24:17 AM6/9/21
to django-...@googlegroups.com
#32830: The 'last' filter in django template default tags give negative index error
-------------------------------------+-------------------------------------
Reporter: sushantg2001 | Owner:
| sushantg2001
Type: Bug | Status: closed

Component: Template system | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: last django- | Triage Stage:
template | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: assigned => closed
* resolution: => invalid


Comment:

The `last` template filter is not intended to work with a queryset but
with a list, see
[https://docs.djangoproject.com/en/3.2/ref/templates/builtins/#last docs].
You can use `{{ queryset.last }}`, which will call
[https://docs.djangoproject.com/en/3.2/ref/models/querysets/#last
QuerySet.last()].

--
Ticket URL: <https://code.djangoproject.com/ticket/32830#comment:2>

Reply all
Reply to author
Forward
0 new messages