question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

False positive for debug_toolbar.W006?

See original GitHub issue

After upgrading to v3.2.3 I get the system warning W006, and an advisement to set APP_DIRS=True for at least one of my template settings.

Shouldn’t that check also be looking at the value of loaders in order to avoid false warnings?

For example, the project in question had the following template settings:

TEMPLATES = [{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [SITE_ROOT / 'templates'],
    'OPTIONS': {
        'builtins': [
            'django.templatetags.static',
            'common.templatetags.builtins',
        ],
        'context_processors': [
            'common.context_processors.constants',
            'django.template.context_processors.debug',
            'django.template.context_processors.request',
            'django.template.context_processors.media',
            'django.contrib.auth.context_processors.auth',
            'django.contrib.messages.context_processors.messages',
        ],
        'loaders': [
            'django.template.loaders.filesystem.Loader',
            'django.template.loaders.app_directories.Loader',
        ],
    },
}]

Django Debug Toolbar works wonderfully with these settings. My understanding is that the app_directories loader is able to find the templates that the toolbar needs. The W0006 warning seems to be a false postive here (but to be honest, it’s been a couple of years since I created this config).

As a quick experiment I tried just deleting the loaders option and adding the suggested APP_DIRS setting. It resulted in a key error for ‘django’ during deployment while trying to run migrate - so I’ve reverted back to v3.2.2 for now.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
matthiaskcommented, Dec 16, 2021

We could make the check a bit smarter by inspecting ...["OPTIONS"]["loaders"].

0reactions
tim-schillingcommented, Dec 18, 2021

I attempted to do this and discovered, that Django automatically adds the cached loader since 1.11 when “debug” is False: django/django@277fe2e

@matthiask it looks like that loader isn’t included when debug = True, so it shouldn’t matter for the toolbar.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django Debug Toolbar - Read the Docs
If set to False, the debug toolbar will keep the contents of panels in memory on the server and load them on demand....
Read more >
Change log — Django Debug Toolbar 3.8.1 documentation
Add check W006 to warn that the toolbar is incompatible with TEMPLATES settings configurations with APP_DIRS set to False .
Read more >
16.2. Debugging (The definitive guide of Symfony 1.0)
It gives access to the symfony log events, the current configuration, the properties of the request and response objects, the details of the...
Read more >
Danfoss PLUS+1 GUIDE Software Release Notes
This led to a false positive compatibility-mode popup warning. This has now been fixed. [P100003038]. Routing signals with names that would be ...
Read more >
django-debug-toolbar not showing up - Stack Overflow
Because Django sets DEBUG=False during tests, but seemingly only after settings.py has been imported, the app and middleware were getting installed and the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found