Pycharm suddenly not detecting ANY Django tags in template

After a recent update Pycharm has started to throw warnings for any bit of Django template code. {% load %} tags, {% if %} or {% for %} loops, static files; anything.

Everything runs fine, I just have tons of warnings in my code that aren't accurate or helpful. 

I have invalidated cache, triple-checked my INSTALLED_APPS and my settings.py in general. Again, it's working fine. Just throwing warnings that make no sense.

13 comments

Hi,

Well, this is not normal. Please ensure that HTML is enabled as a file type for Django templates under **File | Settings/Preferences | Languages & Frameworks | Python Template Languages**

Does the issue reproduce if you create a new minimal project and test there?

I would also suggest to back up your settings (File > Export settins), then reset all settings to default by deleting the config directory (https://intellij-support.jetbrains.com/hc/en-us/articles/206544519) and check after that. This will show us if the issue was in your settings after all. Then you can import the settings back.

1

HTML is enabled as a file type for Python Template languages for Django. Will try wiping all settings.

 

1

Wiped all settings as described above and the problem persists.

Is my project structure setup correctly?

1

Everything looks correct on the screenshot. Does the issue reproduce every time in every project? If yes, please create a new project with some minimal code, ensure the issue is reproduced, and upload the zipped project to our FTP so we could try and reproduce inhouse (https://uploads.services.jetbrains.com/). After uploading, let me know the file name.

If the issue is only specific to your current project, let me know.

0

Created a new Django project with a similar basic format. The issue persists.

 

Filename is "pycharm_template_inspection_issues.zip"

1

I am encountering the exact same issue. My settings.py is correctly set up, project structure is as suggested, Django support is obviously enabled and points to the correct folders and files, template language is django and html files are included.

Strangely, autocompletion/suggestions for paths pointing from templates to other templates or static files work fine. The extends, include and the block tags are apparently recognized normally by PyCharm, but all other tags so far (i.e. load, if, for, static, url) are highlighted as "unresolved tag".

Currently trying out the professional version:

PyCharm 2019.1.1 (Professional Edition)
Build #PY-191.6605.12, built on April 3, 2019
Licensed to PyCharm Evaluator
Expiration date: May 27, 2019
JRE: 11.0.2+9-b159.34 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

Django support was a major argument for getting the pro version, so it would be nice if this was fixed. Any help is greatly appreciated.

1

@iamjonmiller

Thanks for the project. Unfortunately I can't reproduce the issue, the tags are resolved correctly for me.

Please provide log files (can be located according to https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files), your Python and Django versions.

0

Just spent my morning resetting my environment twice. Despite uninstalling Pycharm, removing all associated caches, registry keys, settings, temp data, and even deleting the .idea folder in my project, and then doing a fresh install with no imported settings; the issue remains. As soon as Pycharm loads up my project and inspects it, it is riddled with inaccurate error messages.

I uploaded my logs to the link you provided earlier. Filename is "jmiller-pycharm-logs-20190508-114029.zip"

1

What @df describes is exactly my issue.

1

Could you please provide the

pip freeze

output for the interpreter used by the project? The problem is reproducible for me while no interpreter is selected, but as soon as I point the project to the Python with Django installed it starts to resolve tags correctly.

0

@Pavel Not sure why that would be helpful for finding the problem, but here you go:

beautifulsoup4==4.7.1                                                                                                   
certifi==2019.3.9                                                                                                       
chardet==3.0.4                                                                                                          
colorama==0.4.1                                                                                                         
dataclasses==0.6                                                                                                        
Django==2.2.1                                                                                                           
django-crispy-forms==1.7.2                                                                                              
django-filter==2.1.0                                                                                                    
django-stubs==0.12.1                                                                                                    
djangorestframework==3.9.3                                                                                              
djangorestframework-stubs==0.4.2                                                                                        
httpie==1.0.2                                                                                                           
idna==2.8                                                                                                               
multiprocessing-logging==0.2.6                                                                                          
mypy==0.701                                                                                                             
mypy-extensions==0.4.1                                                                                                  
mysql-connector-python==8.0.16                                                                                          
mysqlclient==1.4.0                                                                                                      
protobuf==3.7.1                                                                                                         
Pygments==2.3.1                                                                                                         
pytz==2019.1                                                                                                            
PyYAML==5.1                                                                                                             
requests==2.21.0                                                                                                        
selenium==3.141.0                                                                                                       
six==1.12.0                                                                                                             
soupsieve==1.9.1                                                                                                        
sqlparse==0.3.0                                                                                                         
typed-ast==1.3.5                                                                                                        
typing-extensions==3.7.2                                                                                                
urllib3==1.24.3                                                                                                         

Suffice it to say, I have of course pointed Pycharm to the correct interpreter, that being the virtual environment created using pipenv. And yes, Django is installed in that virtual environment.

Here is a screenshot:

By the way, the recent update to PyCharm did not fix the problem. Please let me know, if I should wait with buying a license until you fixed the problem since this is an important issue for me.

1

Could you please remove django-stubs? It seems to cause the problem.

0

Thank you, this actually solved the issue (for me)! Intresting, why that is though. Since I currently don't need these stubs packages, this solution is fine for the moment.

(It may be worth noting for someone with the same issue that to remove django-stubs, djangorestframework-stubs had to be removed as well due to the latter's dependency on the former.)

0

Please sign in to leave a comment.