PyCharm 5 can't find Django 1.9 templates

2019-05-03 19:16发布

问题:

When I'm debugging my app with PyCharm 5.0.3, I want to insert a few breakpoints into template files (Django 1.9).

However, when I run app in PyCharm debug mode, it prints the following warning as soon as it processes the first request.

WARNING: Template path is not available. Please set TEMPLATE_DEBUG=True in your settings.py to make django template breakpoints working

I've read here that TEMPLATE_DEBUG has been deprecated and I already have this setting in the new format. I've also tried marking the templates directory as "Template Folder" as per another Stackoverflow post, but it doesn't help.

Has anyone seen this issue before? Here are my settings

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
DEBUG = True
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'debug': DEBUG,
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

回答1:

I got a reply from PyCharm, it's a known issue and will be fixed in then next release.

https://youtrack.jetbrains.com/issue/PY-17923