Django support does not recognize always loaded custom template tags

Answered

Django supports autoloading of custom template tags in every template without having to call {% load xxx %} inside every template. (https://gilang.chandrasa.com/blog/autoload-custom-template-tags-in-django/)

PyCharm does not seem to recognize this.

In my case (Django 2.0, PyCharm Professional 2018.1) i have a base.py inside MyAppName.templatetags with my custom tags and i made them "global" by adding them to the builtins like this: (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',
                'BIAdmin.context_processors.menu_entries',
            ],
            'builtins': ['MyAppName.templatetags.base']
        },
    },
]

This works great but i don't get autocomplete for the custom tags, unless i use "{%load base %}" inside every template.

Is there a possibility to get autocomplete by the IDE for this kind of "always loaded" custom template tags, too?

 

Greetings

Danny

1
1 comment
Official comment

Hello.

This functionality is not supported yet. I created a feature request: https://youtrack.jetbrains.com/issue/PY-30260 

Please, vote for it.

Please sign in to leave a comment.