#35395 closed Bug (fixed)
Python 3.12 filter bug with Django 4.2.11 — at Version 2
Reported by: | Tim Richardson | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 4.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
I have a template with a fragment like this:
<span class="fs-6">Supplier: {{ po_metadata|get_item:dict_item.PONumber|get_item:"supplier" }} PO Date: {{ po_metadata|get_item:dict_item.PONumber|get_item:"order_date" | slice:":10" }} </span>
When using python 3.13.2, I get an exception in django/template/defaultfilters.py slice_filter()
This code does not throw an exception with 3.11
The exception is a Key Error and it happens because instead a list being passed to the filter, a dictionary is. An empty dict in my case.
In python 3.11, the breakpoints in slice_filter() are not hit. Somehow the preceeding filters are behaving differently in case of po_metadata being an empty dict.
Change History (2)
comment:1 by , 7 months ago
Description: | modified (diff) |
---|
comment:2 by , 7 months ago
Description: | modified (diff) |
---|---|
Resolution: | → needsinfo |
Status: | new → closed |
Hi Tim, You haven't provided complete steps to reproduce the issue as your snippet involves custom template filters. The issue may be in those filters. You should debug the problem and confirm that Django is at fault. If so, reopen the issue with an explanation. See TicketClosingReasons/UseSupportChannels if you need help.