[Fixed]-PyCharm does not resolve templates nor template tags nor statics in Django project

27👍

Please try this – it works for me for templates:

  • set templates directories in Python Template Languages -> Template directories
  • in Project Structure mark your apps as Source Folders

EDIT :
After a project structure reorganization I had problem with static files again. Setting destination of setting.py file in Django Support -> Settings resolved the issue.

👤glowka

14👍

Right click on the templates directory and “Mark Directory As” -> “Template Directory” and select template language as django

13👍

I’ve solved this problem by editing settings for Django framework, as seen on a picture.
PICTURE

11👍

You need to set up your project properly.

Django Set Up

In Preferences | Languages & Frameworks | Django, Enable Django Suport, set up the path to your project’s root, settings.py file, and manage.py file:

enter image description here

Mark your templates directory as Templates

In File | Settings | Project Structure for Windows/Linux and
PyCharm | Preferences | Project Structure for macOS, choose the directory to be marked as a template root.

enter image description here

Click on Templates on Mark as.

enter image description here

  1. Click on OK to apply the changes you made.

0👍

The issue for me was that I was doing this in my settings module:

INSTALLED_APPS = [*INSTALLED_APPS, "debug_toolbar"]

This caused PyCharm to think that debug_toolbar is the only app in the entire project. Declaring INSTALLED_APPS in the standard way solved it.

👤damd

Leave a comment