﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30978	Missing configuration step with custom filters.	blueglyph	nobody	"Target documentation page: [https://docs.djangoproject.com/en/2.2/howto/custom-template-tags/]

It seems the TEMPLATES settings must include a new element in order to properly register custom filters:
{{{
 ['OPTIONS']['libraries']
}}}


My structure is:


{{{
profile/
- __init__.py
- models.py
- urls.py
- views.py
- templetags/
- - __init__.py
- - filters.py

templates/
- profile/
- - overview.html

}}}

Excerpt of filters.py:

{{{
from profile.models import Profile
from django import template

register = template.Library()

@register.filter(name='she_he')
def she_he(profile: Profile, cap=False):
	pronoun = 'she' if profile.gender == 'F' else 'he'
	return pronoun.capitalize() if cap else pronoun
}}}

Excerpt of overview.html:

{{{
{% extends ""base.html"" %}
{% load filters %}
{% block content %}
<p>{{ profile|her_his }} current role
}}}

My app is declared in INSTALLED_APPS, and it worked before I added the filter and the load in the template.
Yet I got this error:


{{{
'filters' is not a registered tag library. Must be one of:
[...]
}}}



To make it work, I had to add the 'libraries' item in TEMPLATES, in settings.py:


{{{
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')]
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
            'libraries': {
                'filters': 'profile.templetags.filters'
            }
        },
    },
]

}}}

I don't see that on that page, which makes it very confusing.
"	Uncategorized	closed	Documentation	2.2	Normal	invalid	filters, configuration		Unreviewed	0	0	0	0	0	0
