Custom template filter 3.2.18 -> 4.17

Hello hello,

I have a custom template filter that works perfectly under django 3.2.18.

When switching to django 4.1.7, I get :

django.template.exceptions.TemplateSyntaxError: Invalid filter: 'daysuntil'

Simplified version:

from django import template
from django.utils import timezone

register = template.Library()

def daysuntil(d,
    return 1

folder structure:

|__ portal_core
      |__ templatetags



just switching the django version causes it to break.

Any idea? something I missed in the release notes? :[

EDIT (template) =============
Exception when template is used/loaded/requested:

  File "/env/lib/python3.11/site-packages/django/template/", line 154, in __init__
    self.nodelist = self.compile_nodelist()
  File "/env/lib/python3.11/site-packages/django/template/", line 200, in compile_nodelist
    return parser.parse()
  File "/env/lib/python3.11/site-packages/django/template/", line 484, in parse
    raise self.error(token, e)
  File "/env/lib/python3.11/site-packages/django/template/", line 482, in parse
    filter_expression = self.compile_filter(token.contents)
  File "/env/lib/python3.11/site-packages/django/template/", line 600, in compile_filter
    return FilterExpression(token, self)
  File "/env/lib/python3.11/site-packages/django/template/", line 698, in __init__
    filter_func = parser.find_filter(filter_name)
  File "/env/lib/python3.11/site-packages/django/template/", line 606, in find_filter
    raise TemplateSyntaxError("Invalid filter: '%s'" % filter_name)
django.template.exceptions.TemplateSyntaxError: Invalid filter: 'daysuntil'


{% load static media daysuntil %}
{{ object.event_datetime|daysuntil }}

When the exception is being raised?
When django is loaded or when a template is rendered? If the exception is raised when a template is rendered, please also post the template that uses this filter here.

I’m an idiot.

Wrong template… :slight_smile: